Beispiel #1
0
        /// <summary>
        /// An alternative way to use CreateProfile that uses ProfileExpression
        /// as a Nested Closure.  This usage will result in cleaner code for
        /// multiple declarations
        /// </summary>
        /// <param name="profileName"></param>
        /// <param name="action"></param>
        public void Profile(string profileName, Action <IProfileRegistry> action)
        {
            var registry = new Registry();

            action(registry);

            alter = x => registry.Configure(x.Profile(profileName));
        }
Beispiel #2
0
        /// <summary>
        /// Populates the registry using the specified service descriptors.
        /// </summary>
        /// <remarks>
        /// This method should only be called once per container.
        /// </remarks>
        /// <param name="registry">The registry.</param>
        /// <param name="descriptors">The service descriptors.</param>
        public static void Populate(this Registry registry, IEnumerable <ServiceDescriptor> descriptors)
        {
            // HACK: We insert this action in order to prevent Populate being called twice on the same container.
            registry.Configure(ThrowIfMarkerInterfaceIsRegistered);

            registry.For <IMarkerInterface>();

            registry.Policies.ConstructorSelector <AspNetConstructorSelector>();

            registry.For <IServiceProvider>()
            .LifecycleIs(Lifecycles.Container)
            .Use <StructureMapServiceProvider>();

            registry.For <IServiceScopeFactory>()
            .LifecycleIs(Lifecycles.Container)
            .Use <StructureMapServiceScopeFactory>();

            registry.Register(descriptors);
        }