コード例 #1
0
        /// <summary>
        /// Used to add additional configuration to a Container *after* the initialization.
        /// </summary>
        /// <param name="configure"></param>
        public void Configure(Action <ConfigurationExpression> configure)
        {
            lock (this)
            {
                var registry = new ConfigurationExpression();
                configure(registry);

                PluginGraph graph = registry.BuildGraph();

                graph.Log.AssertFailures();

                _interceptorLibrary.ImportFrom(graph.InterceptorLibrary);
                _pipelineGraph.ImportFrom(graph);
            }
        }
コード例 #2
0
        public void Configure(Action <ConfigurationExpression> configure)
        {
            var registry = new ConfigurationExpression();

            configure(registry);

            var builder = new PluginGraphBuilder(_pluginGraph);

            builder.Add(registry);

            registry.Registries.Each(x => x.As <IPluginGraphConfiguration>().Register(builder));
            registry.Registries.Each(x => builder.Add(x));

            builder.RunConfigurations();
        }
コード例 #3
0
ファイル: Container.cs プロジェクト: hasaki/ragetanks
        public Container(Action <ConfigurationExpression> action)
        {
            var expression = new ConfigurationExpression();

            action(expression);

            // As explained later in the article,
            // PluginGraph is part of the Semantic Model
            // of StructureMap
            PluginGraph graph = expression.BuildGraph();

            // Take the PluginGraph object graph and
            // dynamically emit classes to build the
            // configured objects
            construct(graph);
        }
        /// <summary>
        /// Adds JustSaying services to the registry.
        /// </summary>
        /// <param name="registry">The <see cref="ConfigurationExpression"/> to add JustSaying services to.</param>
        /// <param name="region">The AWS region to configure.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="registry"/> or <paramref name="region"/> is <see langword="null"/>.
        /// </exception>
        public static void AddJustSaying(this ConfigurationExpression registry, string region)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (string.IsNullOrWhiteSpace(region))
            {
                throw new ArgumentException("region must not be null or empty", nameof(region));
            }

            registry.AddJustSaying(
                (builder) => builder.Messaging(
                    (options) => options.WithRegion(region)));
        }
コード例 #5
0
        /// <summary>
        /// Adds JustSaying services to the registry.
        /// </summary>
        /// <param name="registry">The <see cref="ConfigurationExpression"/> to add JustSaying services to.</param>
        /// <param name="regions">The AWS region(s) to configure.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="registry"/> or <paramref name="regions"/> is <see langword="null"/>.
        /// </exception>
        public static void AddJustSaying(this ConfigurationExpression registry, params string[] regions)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (regions == null)
            {
                throw new ArgumentNullException(nameof(regions));
            }

            registry.AddJustSaying(
                (builder) => builder.Messaging(
                    (options) => options.WithRegions(regions)));
        }
コード例 #6
0
        public void Configure(Action <ConfigurationExpression> configure)
        {
            if (_pluginGraph.IsRunningConfigure)
            {
                throw new StructureMapConfigurationException("The container is already being configured. Recursive IContainer.Configure() calls are not allowed");
            }

            _pluginGraph.IsRunningConfigure = true;

            try
            {
                var registry = new ConfigurationExpression();
                configure(registry);

                if (registry.HasPolicyChanges() && Role == ContainerRole.Nested)
                {
                    throw new StructureMapConfigurationException("Policy changes to a nested container are not allowed. Policies can only be applied to the root container");
                }

                if (registry.HasPolicyChanges())
                {
                    _pluginGraph.ClearTypeMisses();
                }

                var builder = new PluginGraphBuilder(_pluginGraph);
                builder.Add(registry);

                registry.Registries.Each(x => builder.Add(x));

                builder.RunConfigurations();

                if (registry.HasPolicyChanges())
                {
                    Instances.GetAllInstances().ToArray().Each(x => x.ClearBuildPlan());

                    Profiles.AllProfiles().ToArray()
                    .Each(x => x.Instances.GetAllInstances().ToArray().Each(i => i.ClearBuildPlan()));
                }
            }
            finally
            {
                _pluginGraph.IsRunningConfigure = false;
            }
        }
コード例 #7
0
        public void Configure(Action <ConfigurationExpression> configure)
        {
            var registry = new ConfigurationExpression();

            configure(registry);

            var builder = new PluginGraphBuilder(_pluginGraph);

            builder.Add(registry);

            registry.Registries.Each(x => x.As <IPluginGraphConfiguration>().Register(builder));
            registry.Registries.Each(x => builder.Add(x));

            builder.RunConfigurations();

            if (registry.HasPolicyChanges())
            {
                Instances.GetAllInstances().ToArray().Each(x => x.ClearBuildPlan());

                Profiles.AllProfiles().ToArray()
                .Each(x => x.Instances.GetAllInstances().ToArray().Each(i => i.ClearBuildPlan()));
            }
        }
コード例 #8
0
 protected bool Equals(ConfigurationExpression other)
 {
     return(false);
 }
コード例 #9
0
 /// <summary>
 /// Populates the container using the specified service descriptors.
 /// </summary>
 /// <param name="config">The configuration.</param>
 /// <param name="descriptors">The service descriptors.</param>
 public static void Populate(this ConfigurationExpression config, IEnumerable <ServiceDescriptor> descriptors)
 {
     config.Policies.ConstructorSelector <AspNetConstructorSelector>();
     config.AddRegistry(new ServiceCollectionRegistry(descriptors));
 }
 /// <summary>
 /// Populates the container using the specified service descriptors.
 /// </summary>
 /// <remarks>
 /// This method should only be called once per container.
 /// </remarks>
 /// <param name="config">The configuration.</param>
 /// <param name="descriptors">The service descriptors.</param>
 /// <param name="checkDuplicateCalls">Specifies whether duplicate calls to Populate should throw.</param>
 public static void Populate(this ConfigurationExpression config, IEnumerable <ServiceDescriptor> descriptors, bool checkDuplicateCalls)
 {
     ((Registry)config).Populate(descriptors, checkDuplicateCalls);
 }
 /// <summary>
 /// Populates the container using the specified service descriptors.
 /// </summary>
 /// <remarks>
 /// This method should only be called once per container.
 /// </remarks>
 /// <param name="config">The configuration.</param>
 /// <param name="descriptors">The service descriptors.</param>
 public static void Populate(this ConfigurationExpression config, IEnumerable <ServiceDescriptor> descriptors)
 {
     config.Populate(descriptors, checkDuplicateCalls: false);
 }
コード例 #12
0
 /// <summary>
 /// Populates the container using the specified service descriptors.
 /// </summary>
 /// <remarks>
 /// This method should only be called once per container.
 /// </remarks>
 /// <param name="config">The configuration.</param>
 /// <param name="descriptors">The service descriptors.</param>
 public static void Populate(this ConfigurationExpression config, IEnumerable <ServiceDescriptor> descriptors)
 {
     Populate((Registry)config, descriptors);
 }