forked from paypal/paypalhttp_dotnet
-
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.
serializer regex refactor, version 1.7
- Loading branch information
1 parent
e1f1f4f
commit 36b3b7c
Showing
10 changed files
with
560 additions
and
74 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace PayPalHttp | ||
{ | ||
public class TextSerializer : ISerializer | ||
{ | ||
private const string RegExPattern = "^text/.*$"; | ||
private static readonly Regex _pattern = new Regex(RegExPattern, RegexOptions.Compiled); | ||
|
||
public object Decode(HttpContent content, Type responseType) | ||
{ | ||
return content.ReadAsStringAsync().Result; | ||
} | ||
|
||
public string GetContentTypeRegexPattern() | ||
public HttpContent Encode(HttpRequest request) | ||
{ | ||
return "^text/.*$"; | ||
return new StringContent(request.Body.ToString()); | ||
} | ||
|
||
public HttpContent Encode(HttpRequest request) | ||
public Regex GetContentRegEx() | ||
{ | ||
return new StringContent(request.Body.ToString()); | ||
return _pattern; | ||
} | ||
|
||
public string GetContentTypeRegexPattern() | ||
{ | ||
return RegExPattern; | ||
} | ||
} | ||
} |