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
[Fact] | |
public async Task DispatchBasedOnStatusCodeMediaTypeAndProfile() | |
{ | |
Person testPerson = null; | |
var machine = new HttpResponseMachine(); | |
// Define method to translate response body into DOM for specified media type | |
machine.AddMediaTypeParser<JToken>("application/json", async (content) => | |
{ |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
ServicePointManager.DefaultConnectionLimit = 2; | |
var tasks = new Task[10]; | |
for (int i = 0; i < 10; i++) | |
{ | |
tasks[i] = Run(); |
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
public class RunscopePassagewayHandler : DelegatingHandler { | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { | |
if (request.RequestUri.Host.Contains("passageway.io")) { | |
var uriWithoutPort = request.RequestUri.GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped); | |
request.RequestUri = new Uri(uriWithoutPort); | |
} | |
return base.SendAsync(request, cancellationToken); | |
} | |
} |
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
1) Remove all nuget packages with any relationship to the package having a problem | |
2) Ensure that no project still has a DLL reference to assemblies from those nuget packages | |
3) Remove all binding redirects related to these nuget packages | |
4) Add nuget packages, one at a time, in order of dependencies. (i.e. Don't let any nuget package automatically pull in another) | |
5) Add binding redirects for anything that still has a problem | |
6) Enjoy the build successful | |
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
public static class TaskHelper | |
{ | |
public static Task<T> RunWithCancel<T>(Func<CancellationToken,T> function, CancellationToken token) | |
{ | |
return Task.Run(() => function(token),token); | |
} | |
} |
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
public class NullJsonHandler : DelegatingHandler | |
{ | |
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) | |
{ | |
var response = await base.SendAsync(request, cancellationToken); | |
if (response.Content == null) | |
{ | |
response.Content = new StringContent("{}"); |
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
public static Func<IDictionary<string, object>, Task> CreateWebApiAppFunc(HttpConfiguration config) | |
{ | |
var app = new HttpServer(config); | |
var options = new HttpMessageHandlerOptions() | |
{ | |
MessageHandler = app, | |
BufferPolicySelector = new OwinBufferPolicySelector(), | |
ExceptionLogger = new WebApiExceptionLogger(), | |
ExceptionHandler = new WebApiExceptionHandler() | |
}; |
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
public static IDisposable CreateHttpListenerServer(Uri baseAddress, Func<IDictionary<string, object>, Task> appFunc) | |
{ | |
var props = new Dictionary<string, object>(); | |
var address = Address.Create(); | |
address.Host = baseAddress.Host; | |
address.Port = baseAddress.Port.ToString(); | |
address.Scheme = baseAddress.Scheme; | |
address.Path = baseAddress.AbsolutePath; |
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
public class JsonStringController : ApiController | |
{ | |
public HttpResponseMessage Post([FromBody]string jsonBody) | |
{ | |
var myobject = Newtonsoft.Json.JsonConvert.DeserializeObject<MyObject>(jsonBody) | |
return new HttpResponseMessage(HttpStatusCode.Created); | |
} | |
} |
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
class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
var webApiconfig = new HttpConfiguration(); | |
webApiconfig.Routes.MapHttpRoute("test","Test",new {controller="Test"}); | |
app.UseWebApi(webApiconfig); | |
// Turn cross domain on | |
var config = new HubConfiguration { EnableCrossDomain = true }; |
OlderNewer