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 GistSuperSimpleViewEngineExtension : ISuperSimpleViewEngineExtension | |
{ | |
private readonly Regex regex = new Regex(@"(?:@gist\[(?<id>[a-z01-9]*)\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); | |
private const string GistTemplate = "<script src='https://gist.github.com/{0}.js'></script>"; | |
public string Invoke(string content, dynamic model, IViewEngineHost host) | |
{ | |
return regex.Replace(content, match => (match.Groups["id"].Success) ? string.Format(GistTemplate, match.Groups["id"].Value) : string.Empty); | |
} | |
} |
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 interface ISuperSimpleViewEngineExtension | |
{ | |
string Invoke(string content, dynamic model, IViewEngineHost host); | |
} | |
public class GistSuperSimpleViewEngineExtension : ISuperSimpleViewEngineExtension | |
{ | |
private readonly Regex regex = new Regex(@"(?:@gist\[(?<id>[a-z01-9]*)\])", RegexOptions.Compiled | RegexOptions.IgnoreCase); | |
private const string GistTemplate = "<script src='https://gist.github.com/{0}.js'></script>"; |
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 CustomeOwinHost | |
{ | |
private readonly Func<IDictionary<string, object>, Task> next; | |
public CustomeOwinHost(Func<IDictionary<string, object>, Task> next, string foo) | |
{ | |
this.next = next; | |
} | |
public Task Invoke(IDictionary<string, object> environment) |
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 RequestStream(Stream stream, long expectedLength, long thresholdLength, bool disableStreamSwitching) | |
{ | |
this.thresholdLength = thresholdLength; | |
this.disableStreamSwitching = disableStreamSwitching; | |
this.stream = stream ?? this.CreateDefaultMemoryStream(expectedLength); | |
ThrowExceptionIfCtorParametersWereInvalid(this.stream, expectedLength, this.thresholdLength); | |
if (!this.MoveStreamOutOfMemoryIfExpectedLengthExceedExpectedLength(expectedLength)) | |
{ |
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
if (!this.stream.CanSeek) | |
{ | |
var buffer = | |
new MemoryStream((int)this.stream.Length); | |
this.stream.CopyTo(buffer, (source, destination, ex) => | |
{ | |
this.stream = buffer; | |
}); | |
} |
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 static class StreamExtensions | |
{ | |
public static void CopyStreamToStream(this Stream source, Stream destination, Action<Stream, Stream, Exception> completed) | |
{ | |
var buffer = new byte[4096]; | |
var operation = | |
AsyncOperationManager.CreateOperation(null); | |
Action<Exception> done = e => |
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
I don't have VS2012 installed on one of my machines, but .NET Framework 4.5 is. When creating a web project using VS2012 it instists on adding | |
<PropertyGroup> | |
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> | |
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |
</PropertyGroup> | |
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> | |
To the csproj of said project. If I build these outside of VS (in this case using Rake) it will resolve VisualStudioVersion to v11.0, which means will try to look for targets at |
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 RequestStream(Stream stream, long expectedLength, long thresholdLength, bool disableStreamSwitching) | |
{ | |
this.thresholdLength = thresholdLength; | |
this.disableStreamSwitching = disableStreamSwitching; | |
this.stream = stream ?? this.CreateDefaultMemoryStream(expectedLength); | |
ThrowExceptionIfCtorParametersWereInvalid(this.stream, expectedLength, this.thresholdLength); | |
this.MoveStreamOutOfMemoryIfExpectedLengthExceedExpectedLength(expectedLength); | |
this.MoveStreamOutOfMemoryIfContentsLengthExceedThresholdAndSwitchingIsEnabled(); |
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 IndexModule : NancyModule | |
{ | |
public IndexModule() | |
{ | |
Get["/"] = x => { | |
return "Nancy running on ScriptCS!"; | |
}; | |
} | |
} |
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 static JsonSerializer Serializer; | |
public JsonNetSerializer() | |
{ | |
Serializer = GetJsonSerializer(); | |
} | |
private static JsonSerializer GetJsonSerializer() | |
{ | |
if (Serializer != null) |