當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。