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.Net; | |
using System.Text; | |
using RestSharp; | |
namespace RestSharpExtensions | |
{ | |
public static class RestSharpExtensions | |
{ |
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
internal static class MockHttpMessageHandlerHelper | |
{ | |
public static void SetupSendAsync(this Mock<HttpMessageHandler> handler, Func<HttpResponseMessage> sendAsyncResultFunc) | |
{ | |
handler.Protected() | |
.Setup<Task<HttpResponseMessage>>("SendAsync", ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>()) | |
.Returns(Task<HttpResponseMessage>.Factory.StartNew(sendAsyncResultFunc)); | |
} | |
public static void VerifySendAsync(this Mock<HttpMessageHandler> handler, Times times) |
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 SequenceGenerator | |
{ | |
public static IEnumerable<T> Generate<T>(T initialValue, Func<T, T> generator) | |
where T : struct | |
{ | |
var value = initialValue; | |
while (true) | |
{ | |
yield return value; | |
value = generator(value); |
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
Register-TabExpansion 'Get-SolutionPackages' @{ | |
'PackageName' = { Get-Package | Sort-Object -Property Id -Unique | foreach { $_.Id } } | |
} | |
Register-TabExpansion 'Refresh-Package' @{ | |
'PackageName' = { Get-Package | Sort-Object -Property Id -Unique | foreach { $_.Id } } | |
} | |
function Refresh-Package($PackageName) { | |
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 MvcModelBinderTestHelper | |
{ | |
public static ModelBindingContext FakeModelBindingContext<T>(NameValueCollection formCollection) where T : class | |
{ | |
var valueProvider = new NameValueCollectionValueProvider(formCollection, null); | |
var metadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(T)); | |
var bindingContext = new ModelBindingContext | |
{ |
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 HtmlActionResult<T> : IHttpActionResult | |
{ | |
private readonly string _viewTemplate; | |
private readonly T _model; | |
public HtmlActionResult(string viewTemplateFullPath, T model) | |
{ | |
_viewTemplate = File.ReadAllText(viewTemplateFullPath); | |
_model = model; | |
} |
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() { | |
d3.force_labels = function force_labels() { | |
var labels = d3.layout.force(); | |
// Update the position of the anchor based on the center of bounding box | |
function updateAnchor() { | |
if (!labels.selection) return; | |
labels.selection.each(function(d) { | |
var bbox = this.getBBox(), | |
x = bbox.x + bbox.width / 2, |
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
Register-TabExpansion 'Get-SolutionPackages' @{ | |
'PackageName' = { Get-Package | Sort-Object -Property Id -Unique | foreach { $_.Id } } | |
} | |
function Get-SolutionPackages($PackageName) { | |
$nl = [Environment]::NewLine | |
$packageSummaryList = @() | |
Get-Project -All | ForEach-Object { |
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
// taken from: https://github.com/bradwilson/ndc2012/tree/master/NdcDemo | |
public abstract class ApiControllerWithHub<THub> : ApiController | |
where THub : IHub | |
{ | |
private readonly Lazy<IHubContext> _hub = new Lazy<IHubContext>( | |
() => GlobalHost.ConnectionManager.GetHubContext<THub>() | |
); | |
protected IHubContext Hub |
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
param($installPath, $toolsPath, $package, $project) | |
$projectFullName = $project.FullName | |
Write-Host "Copying Docs folder to the root of the solution: $projectFullName" | |
$fileInfo = new-object -typename System.IO.FileInfo -ArgumentList $projectFullName | |
$projectDirectory = $fileInfo.DirectoryName | |
$sourceDirectory = "$installPath\docs" | |
Write-Host $sourceDirectory |