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
| /// <summary> | |
| /// Creates a per request child/nested container | |
| /// </summary> | |
| /// <returns>Request container instance</returns> | |
| protected override ILifetimeScope CreateRequestContainer() | |
| { | |
| return ApplicationContainer.BeginLifetimeScope("AutofacRequestLifetime"); | |
| } | |
| /// <summary> |
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
| A [bootstrapper](https://github.com/NancyFx/Nancy/wiki/Bootstrapper) implementation, for the [Nancy](http://nancyfx.org) framework, based on the Autofac inversion of control container. | |
| ## Usage | |
| When Nancy detects that the `AutofacNancyBootstrapper` type is available in the AppDomain of your application, it will assume you want to use it, rather than the default one. | |
| The easiest way to get the latest version of `AutofacNancyBootstrapper` into your application is to install the `Nancy.Boostrappers.Autofac` nuget. | |
| ## Customizing |
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 void LoadAssembliesWithNancyReferences() | |
| { | |
| if (nancyAssembliesLoaded) | |
| { | |
| return; | |
| } | |
| UpdateAssemblies(); | |
| foreach (var directory in GetAssemblyDirectories()) |
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
| private void RewriteMethod() | |
| { | |
| if (!this.Method.Equals("POST", StringComparison.OrdinalIgnoreCase)) | |
| { | |
| return; | |
| } | |
| var overrides = | |
| new List<Tuple<string, string>> | |
| { |
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
| import pymongo | |
| import sys | |
| connection = pymongo.Connection("mongodb://localhost", safe=True) | |
| db = connection.school | |
| collection = db.students | |
| students = collection.find({}) |
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
| protected virtual IRootPathProvider RootPathProviderNew | |
| { | |
| get | |
| { | |
| var providerType = AppDomainAssemblyTypeScanner | |
| .TypesOf<IRootPathProvider>() | |
| .SingleOrDefault(type => type != typeof(DefaultRootPathProvider)); | |
| if (providerType == null) | |
| { |
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 abstract class ApplicationRegistrations : IApplicationRegistrations | |
| { | |
| private readonly IList<CollectionTypeRegistration> collectionRegistrations = new List<CollectionTypeRegistration>(); | |
| private readonly IList<InstanceRegistration> instanceRegistrations = new List<InstanceRegistration>(); | |
| private readonly IList<TypeRegistration> typeRegistrations = new List<TypeRegistration>(); | |
| public IEnumerable<CollectionTypeRegistration> CollectionTypeRegistrations | |
| { | |
| get { return this.collectionRegistrations; } | |
| } |
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 abstract class ApplicationRegistrations : IApplicationRegistrations | |
| { | |
| private readonly IList<CollectionTypeRegistration> collection = new List<CollectionTypeRegistration>(); | |
| private readonly IList<InstanceRegistration> instance = new List<InstanceRegistration>(); | |
| private readonly IList<TypeRegistration> type = new List<TypeRegistration>(); | |
| public IEnumerable<CollectionTypeRegistration> CollectionTypeRegistrations | |
| { | |
| get { return this.collection; } | |
| } |
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 TypeRegistration<TRegistration> : TypeRegistration | |
| { | |
| public TypeRegistration() | |
| : base(typeof(TRegistration), GetImplementingType()) | |
| { | |
| } | |
| public TypeRegistration(Type defaultImplementingType) | |
| : base(typeof(TRegistration), GetImplementingType(defaultImplementingType)) | |
| { |
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 ApplicationRegistrationsExtensions | |
| { | |
| public static TypeRegistration Type<T>(this IApplicationRegistrations registrations) | |
| { | |
| return new TypeRegistration(typeof(T), AppDomainAssemblyTypeScanner.TypesOf(typeof(T)).Single()); | |
| } | |
| public static TypeRegistration TypeWithDefault<T>(this IApplicationRegistrations registrations, Type defaultType) | |
| { | |
| var type = |