This file contains hidden or 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
[TestMethod] | |
public void ConnegTest() | |
{ | |
var selector = new FormatterSelector(); | |
var response = new HttpResponseMessage(); | |
response.RequestMessage = new HttpRequestMessage(); | |
var headers = response.RequestMessage.Headers; | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/plain")); | |
headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json",0.8)); |
This file contains hidden or 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 ThroughputMessageHandler : DelegatingHandler | |
{ | |
private readonly ILogger _logger; | |
private Timer _timer; | |
private int _count; | |
public ThroughputMessageHandler(ILogger logger) | |
{ | |
_logger = logger; | |
_count = 0; | |
_timer = new Timer(new TimerCallback(timerCallback),null,1000,1000); |
This file contains hidden or 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
typeof (Convert) | |
.GetMethods(BindingFlags.Static|BindingFlags.Public) | |
.Where(m=>m.Name.StartsWith("To")) | |
.Select(m=>m.GetParameters().First().ParameterType) | |
.Distinct() |
This file contains hidden or 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
paul@jupiter:~/GitHub/SignalR% wc -l **/*.cs | grep 'total' | |
13141 total | |
paul@jupiter:~/GitHub/SignalR% wc -l **/*.js | grep 'total' | |
94225 total |
This file contains hidden or 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
// From http://msdn.microsoft.com/en-us/magazine/cc163467.aspx | |
internal class AsyncResult : IAsyncResult | |
{ | |
// Fields set at construction which never change while | |
// operation is pending | |
readonly AsyncCallback m_AsyncCallback; | |
readonly Object m_AsyncState; | |
// Fields set at construction which do change after | |
// operation completes |
This file contains hidden or 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
### Check me into the root of the repo | |
### as .gitattributes | |
*.doc diff=astextplain | |
*.DOC diff=astextplain | |
*.docx diff=astextplain | |
*.DOCX diff=astextplain | |
*.dot diff=astextplain | |
*.DOT diff=astextplain |
This file contains hidden or 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
using System; | |
using System.Net; | |
using System.Net.Http; | |
using System.Web.Http.Controllers; | |
using System.Web.Http.Filters; | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | |
public class InvalidModelStateFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(HttpActionContext actionContext) |
This file contains hidden or 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
using System; | |
using System.IO; | |
using System.Net; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace ResponseEntityProcessor.Handlers | |
{ | |
/// <summary> | |
/// Wraps an inner <see cref="HttpContent"/> and forces the content to be written |
This file contains hidden or 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 AtomPubMediaFormatter : MediaTypeFormatter | |
{ | |
private const string Atom = "application/atom+xml"; | |
public AtomPubMediaFormatter() | |
{ | |
SupportedMediaTypes.Add(new MediaTypeHeaderValue(Atom)); | |
this.AddQueryStringMapping("format", "atom", Atom); | |
} |
OlderNewer