forked from dotnet/interactive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate formatting for http request and response types.
Also switch to attribute-based formatter registration.
- Loading branch information
1 parent
41eda18
commit d4267ea
Showing
17 changed files
with
179 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 0 additions & 127 deletions
127
src/Microsoft.DotNet.Interactive.Formatting/HttpResponseMessageFormattingExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Microsoft.DotNet.Interactive.HttpRequest/Formatting/HttpResponseFormatterSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.DotNet.Interactive.Formatting; | ||
|
||
namespace Microsoft.DotNet.Interactive.HttpRequest; | ||
|
||
internal sealed class HttpResponseFormatterSource : ITypeFormatterSource | ||
{ | ||
IEnumerable<ITypeFormatter> ITypeFormatterSource.CreateTypeFormatters() | ||
{ | ||
yield return new HttpResponseHtmlFormatter(); | ||
yield return new HttpResponsePlainTextFormatter(); | ||
} | ||
|
||
private sealed class HttpResponseHtmlFormatter : TypeFormatter<HttpResponse> | ||
{ | ||
public override string MimeType => HtmlFormatter.MimeType; | ||
|
||
public override bool Format(HttpResponse value, FormatContext context) | ||
{ | ||
value.FormatAsHtml(context); | ||
return true; | ||
} | ||
} | ||
|
||
private sealed class HttpResponsePlainTextFormatter : TypeFormatter<HttpResponse> | ||
{ | ||
public override string MimeType => PlainTextFormatter.MimeType; | ||
|
||
public override bool Format(HttpResponse value, FormatContext context) | ||
{ | ||
value.FormatAsPlainText(context); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.