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
[Auth(Roles = "Admin")] | |
public class FooHub : Hub { | |
[Log] | |
public void Send() { | |
//do something here... | |
} | |
} |
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 Global : System.Web.HttpApplication { | |
protected void Application_Start(object sender, EventArgs e) { | |
GlobalHost.Something.Add(new TheThingsThatRunsOnEverRequestBeforeHubs()); | |
} | |
} |
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
[SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "Class needs references to large number of types.")] | |
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "We're registering the ValidationCache to be disposed by the HttpConfiguration.")] | |
public DefaultServices(HttpConfiguration configuration) | |
{ | |
if (configuration == null) | |
{ | |
throw Error.ArgumentNull("configuration"); | |
} | |
_configuration = configuration; |
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
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | |
using System.Collections.Generic; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Diagnostics.Contracts; | |
namespace System.Threading.Tasks | |
{ | |
/// <summary> | |
/// Helpers for safely using Task libraries. |
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
//From SignalR project | |
using System; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace SignalR |
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
// Func<Task<HttpResponseMessage>> | |
Task<HttpResponseMessage> result = InvokeActionWithAuthorizationFilters(actionContext, cancellationToken, authorizationFilters, () => | |
{ | |
HttpActionBinding actionBinding = actionDescriptor.ActionBinding; | |
Task bindTask = actionBinding.ExecuteBindingAsync(actionContext, cancellationToken); | |
return bindTask.Then<HttpResponseMessage>(() => | |
{ | |
_modelState = actionContext.ModelState; | |
Func<Task<HttpResponseMessage>> invokeFunc = InvokeActionWithActionFilters(actionContext, cancellationToken, actionFilters, () => | |
{ |
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
Function encrypt-envelope ($unprotectedcontent, $cert) | |
{ | |
[System.Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null | |
$utf8content = [Text.Encoding]::UTF8.GetBytes($unprotectedcontent) | |
$content = New-Object Security.Cryptography.Pkcs.ContentInfo ` |
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
protected void Application_Start(object sender, EventArgs e) { | |
var config = GlobalConfiguration.Configuration; | |
var routes = config.Routes; | |
routes.MapHttpRoute( | |
"DefaultHttpRoute", | |
"api/{controller}/{id}", | |
new { id = RouteParameter.Optional }, | |
new { |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Net.Http; | |
using System.Web.Http; | |
using System.Xml.Serialization; | |
namespace MvcApplication56.Controllers { |
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 AsyncFactory { | |
public static Task<int> GetIntAsync() { | |
var tcs = new TaskCompletionSource<int>(); | |
var timer = new System.Timers.Timer(2000); | |
timer.AutoReset = false; | |
timer.Elapsed += (s, e) => { | |
tcs.SetResult(10); |