Format:
Recent snippets for: TheCodeJunkie
namespace Nancy.Formatters { using System; using System.IO; using Newtonsoft.Json; public static class JsonFormatterExtensions { public static Response Json<TModel>(this IResponseFormatter response, TModel model) {
238 Views
no comments
Get["/static"] = parameters => { return View.Static("~/views/index.htm"); };
182 Views
no comments
public Response Foo() { return new FakeEntity(); // C# wont let me do this with implicit cast operators }
130 Views
1 comments
public class Index : NancyModule { public Index() { Get["/"] = x => { return "hi"; }; } }
94 Views
no comments
nancy.nuspec <?xml version="1.0"?> <package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <id>Nancy</id> <version>0.0.0.1</version> <authors>Andreas Håkansson</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.</description>
308 Views
no comments
[Fact] public void Should_return_not_found_response_when_no_nancy_modules_could_be_found() { // Given var request = new Request("GET", "/"); A.CallTo(() => this.locator.GetModules()).Returns(Enumerable.Empty<NancyModule>()); // When var response = this.engine.HandleRequest(request);
129 Views
no comments
public abstract class RequestSpec { protected static IEngine engine; protected static IRequest request; protected static IResponse response; protected RequestSpec() { engine = new Engine(); }
84 Views
no comments
[Subject("Handling a GET request")] public class when_get_request_matched_existing_route { static IEngine engine; static IRequest request; static IResponse response; Establish context = () => { request = new Request("GET", new Uri("/"));
88 Views
no comments
public class Container : IContainer { private readonly Dictionary<Type, Func<IContainer, object>> registrations = new Dictionary<Type, Func<IContainer, object>>(); public void Register<T>(Func<IContainer, object> resolver) { this.registrations.Add(typeof(T), resolver); } public void RegisterSingleton<T>(Func<IContainer, object> resolver)
92 Views
no comments
public class Bootstrapper { public ShellPresentationModel Main { get; private set; } public static void Run() { var locator = new PartRegistryLocator(new[] { new ExtensionRegistry() }); var conventionCatalog = new ConventionCatalog(locator);
124 Views
no comments
Get["/"] = x => { return "This is the root"; }; Get["/Greet"] = x => { return "Hello World"; }; Get["/Greet/{name}"] = x => { return "Hello " + x.name;
83 Views
no comments
R#5 wants to turn var creator = new ConventionPartCreator(registry); into var creator = new ConventionPartCreator(registry); how do I make it stop!?
157 Views
no comments
public class TestRegistry { public TestRegistry() { Defaults(x => { x.Type<Foo>().Contract("Andreas").Identity<IWidget>(); x.Type<Bar>().Contract("Piotr").Identity<IUnity>(); }); Part()
158 Views
no comments
properties {
$base_directory = resolve-path .
$build_directory = "$base_directory\release"
$source_directory = "$base_directory\src"
$tools_directory = "$base_directory\tools"
$version = "1.0.0.0"
}
include .\psake_ext.ps1
373 Views
no comments
public static class Member { /// <summary> /// Retrieves the member that an expression is defined for. /// </summary> /// <param name="expression">The expression to retreive the member from.</param> /// <returns>A <see cref="MemberInfo"/> instance if the member could be found; otherwise <see langword="null"/>.</returns> private static MemberInfo GetTargetMemberInfo(this Expression expression) { switch (expression.NodeType)
204 Views
no comments
public interface IRuleMetadata { [DefaultValue(0)] int ExecutionOrder { get; } } [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] public class RuleAttribute : ExportAttribute, IRuleMetadata { public RuleAttribute(int executionOrder)
747 Views
no comments
public class LoggerRegistry : PartRegistry { public LoggerRegistry() { Part<PartConvention>() .ForTypesMatching(x => x.GetInterfaces().Contains(typeof(ILogger))) .Exports(x => x.Export<ExportConvention>() .ContractType<ILogger>() .ContractName<ILogger>() .Members(m => new[] { m }))
247 Views
no comments
public class ConventionPart<T> : IPartImportsSatisfiedNotification { /// <summary> /// Initializes a new instance of the <see cref="ConventionPart{T}"/> class. /// </summary> public ConventionPart() { } [ImportMany]
340 Views
no comments
public class FakeConventionRegistry : ConventionRegistry { public FakeConventionRegistry() { Part<PartConvention>() .ForTypesMatching(x => x.IsPublic && x.IsAbstract == false) .MakeShared() .Imports(x => { x.Import<ImportConvention>()
144 Views
no comments
public class MyConventionRegistry : ConventionRegistry { public MyConventionRegistry() { Part<PartConvention>() .ForTypesMatching(x => x.Name.StartsWith("Foo")) .MakeNonShared() .Imports(i => { i.Import<ImportConvention>().As<IImportConvention>();
171 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
