当前位置: 首页>>代码示例>>C#>>正文


C# Pipeline.ConfiguredInstance类代码示例

本文整理汇总了C#中StructureMap.Pipeline.ConfiguredInstance的典型用法代码示例。如果您正苦于以下问题:C# ConfiguredInstance类的具体用法?C# ConfiguredInstance怎么用?C# ConfiguredInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfiguredInstance类属于StructureMap.Pipeline命名空间,在下文中一共展示了ConfiguredInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Can_NOT_be_plugged_in_if_plugged_type_cannot_be_cast_to_the_plugin_type

        public void Can_NOT_be_plugged_in_if_plugged_type_cannot_be_cast_to_the_plugin_type()
        {
            var instance = new ConfiguredInstance(typeof (ColorRule));
            var family = new PluginFamily(typeof (IWidget));

            instance.As<IDiagnosticInstance>().CanBePartOfPluginFamily(family).ShouldBeFalse();
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:7,代码来源:ConfiguredInstanceTester.cs

示例2: can_build_a_simple_class_type

 public void can_build_a_simple_class_type()
 {
     var instance = new ConfiguredInstance(typeof (Rule1));
     var rule = instance.Build<Rule>(_session);
     rule.ShouldNotBeNull();
     rule.ShouldBeOfType<Rule1>();
 }
开发者ID:goraw,项目名称:structuremap,代码行数:7,代码来源:ConfiguredInstanceTester.cs

示例3: get_the_default_instance_when_it_exists

        public void get_the_default_instance_when_it_exists()
        {
            var instance = new ConfiguredInstance(typeof (Service<>));
            family.SetDefault(instance);

            configuration.Default.ConcreteType.ShouldEqual(typeof (Service<>));
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:7,代码来源:GenericFamilyConfigurationTester.cs

示例4: Use

        /// <summary>
        /// Convenience method that sets the default concrete type of the PluginType.  The "concreteType"
        /// can only accept types that do not have any primitive constructor arguments.
        /// StructureMap has to know how to construct all of the constructor argument types.
        /// </summary>
        /// <param name="concreteType"></param>
        /// <returns></returns>
        public ConfiguredInstance Use(Type concreteType)
        {
            var instance = new ConfiguredInstance(concreteType);
            Use(instance);

            return instance;
        }
开发者ID:goraw,项目名称:structuremap,代码行数:14,代码来源:GenericFamilyExpression.cs

示例5: can_set_scope_directly_on_the_instance

        public void can_set_scope_directly_on_the_instance()
        {
            var i1 = new ConfiguredInstance(GetType()).Named("foo");
            i1.SetLifecycleTo(Lifecycles.ThreadLocal);

            i1.Lifecycle.ShouldBeOfType<ThreadLocalStorageLifecycle>();
        }
开发者ID:e-tobi,项目名称:structuremap,代码行数:7,代码来源:InstanceTester.cs

示例6: can_use_a_configured_instance_with_generic_template_type_and_arguments

        public void can_use_a_configured_instance_with_generic_template_type_and_arguments()
        {
            var instance = new ConfiguredInstance(typeof (Service2<>), typeof (string));
            var container = new Container();

            container.GetInstance<IService<string>>(instance).ShouldBeOfType(typeof (Service2<string>));
        }
开发者ID:goraw,项目名称:structuremap,代码行数:7,代码来源:ConfiguredInstanceTester.cs

示例7: LoadAppropriateStoreRegistry

 public static void LoadAppropriateStoreRegistry(IContainer initContainer)
 {
     var store = initContainer.GetInstance<IRRConfiguration>().ContentStore;
     if (store == Configuration.Store.SqlServerStore)
     {
         var sqlAssembly = Assembly.Load("RequestReduce.SqlServer");
         initContainer.Configure(x =>
                                     {
                                         x.For(sqlAssembly.GetType("RequestReduce.SqlServer.IFileRepository"))
                                             .Use(
                                                 sqlAssembly.GetType(
                                                     "RequestReduce.SqlServer.FileRepository"));
                                         var diskStore =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.SqlServerStore"));
                                         var diskCache =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.DbDiskCache"));
                                         x.For<LocalDiskStore>().Singleton()
                                             .Use(diskCache);
                                         diskStore.CtorDependency<LocalDiskStore>("fileStore").Is(
                                             initContainer.GetInstance<LocalDiskStore>());
                                         diskStore.CtorDependency<IUriBuilder>("uriBuilder").Is(
                                             initContainer.GetInstance<IUriBuilder>());
                                         diskStore.CtorDependency<IReductionRepository>("reductionRepository").Is(
                                             initContainer.GetInstance<IReductionRepository>());
                                         x.For<IStore>().LifecycleIs(new RRHybridLifecycle())
                                             .Use(diskStore);
                                     });
     }
     else
         initContainer.Configure(x => x.AddRegistry<RRLocalStoreRegistry>());
 }
开发者ID:andrewdavey,项目名称:RequestReduce,代码行数:33,代码来源:RRContainer.cs

示例8: InstanceMementoPropertyReader

 public InstanceMementoPropertyReader(ConfiguredInstance instance, InstanceMemento memento,
     PluginGraph pluginGraph, Type pluginType)
 {
     _instance = instance;
     _memento = memento;
     _pluginGraph = pluginGraph;
     _pluginType = pluginType;
 }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:8,代码来源:InstanceMementoPropertyReader.cs

示例9: get_settable_properties

        public void get_settable_properties()
        {
            IConfiguredInstance instance
                = new ConfiguredInstance(typeof(GuyWithProperties));

            instance.SettableProperties()
                .Single().Name.ShouldBe("Widget");
        }
开发者ID:joelweiss,项目名称:structuremap,代码行数:8,代码来源:iconfigured_instance_behavior.cs

示例10: BuildRule1

        public void BuildRule1()
        {
            var instance = new ConfiguredInstance(typeof (Rule1));

            var rule = (Rule) instance.Build(typeof (Rule), _session);
            Assert.IsNotNull(rule);
            Assert.IsTrue(rule is Rule1);
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:8,代码来源:ConfiguredInstanceTester.cs

示例11: Can_be_plugged_in_if_there_is_a_plugged_type_and_the_plugged_type_can_be_cast_to_the_plugintype

        public void Can_be_plugged_in_if_there_is_a_plugged_type_and_the_plugged_type_can_be_cast_to_the_plugintype()
        {
            var instance = new ConfiguredInstance(typeof (ColorWidget));
            var family = new PluginFamily(typeof (IWidget));

            IDiagnosticInstance diagnosticInstance = instance;
            Assert.IsTrue(diagnosticInstance.CanBePartOfPluginFamily(family));
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:8,代码来源:ConfiguredInstanceTester.cs

示例12: Add

        /// <summary>
        /// Shortcut method to add an additional Instance to this Plugin Type
        /// as just a Concrete Type.  This will only work if the Concrete Type
        /// has no primitive constructor or mandatory Setter arguments.
        /// </summary>
        /// <param name="concreteType"></param>
        /// <returns></returns>
        public ConfiguredInstance Add(Type concreteType)
        {
            var instance = new ConfiguredInstance(concreteType);

            alterAndContinue(family => family.AddInstance(instance));

            return instance;
        }
开发者ID:Kingefosa,项目名称:structuremap,代码行数:15,代码来源:GenericFamilyExpression.cs

示例13: instance_key_is_predictable

        public void instance_key_is_predictable()
        {
            var i1 = new ConfiguredInstance(GetType()).Named("foo");
            var i2 = new ConfiguredInstance(GetType()).Named("bar");

            i1.InstanceKey(GetType()).ShouldEqual(i1.InstanceKey(GetType()));
            i2.InstanceKey(GetType()).ShouldEqual(i2.InstanceKey(GetType()));
            i1.InstanceKey(GetType()).ShouldNotEqual(i2.InstanceKey(GetType()));
            i1.InstanceKey(typeof(InstanceUnderTest)).ShouldNotEqual(i1.InstanceKey(GetType()));
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:10,代码来源:InstanceTester.cs

示例14: still_chooses_PerRequest_if_nothing_is_selected_on_either_family_or_instance

        public void still_chooses_PerRequest_if_nothing_is_selected_on_either_family_or_instance()
        {
            var family = new PluginFamily(GetType());

            var i1 = new ConfiguredInstance(GetType()).Named("foo");

            family.AddInstance(i1);

            i1.Lifecycle.ShouldBeOfType<TransientLifecycle>();
        }
开发者ID:smerrell,项目名称:structuremap,代码行数:10,代码来源:InstanceTester.cs

示例15: build_fails_with_StructureMapException_adds_context

        public void build_fails_with_StructureMapException_adds_context()
        {
            var instance = new ConfiguredInstance(typeof(ClassThatBlowsUp));

            var actual =
                Exception<StructureMapBuildException>.ShouldBeThrownBy(() => { instance.Build<ClassThatBlowsUp>(); });

            actual.Message.ShouldContain(instance.Description);
            actual.ShouldBeOfType<StructureMapBuildException>();
        }
开发者ID:joelweiss,项目名称:structuremap,代码行数:10,代码来源:ConfiguredInstanceTester.cs


注:本文中的StructureMap.Pipeline.ConfiguredInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。