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


C# PluginFamily.AddInstance方法代码示例

本文整理汇总了C#中StructureMap.Graph.PluginFamily.AddInstance方法的典型用法代码示例。如果您正苦于以下问题:C# PluginFamily.AddInstance方法的具体用法?C# PluginFamily.AddInstance怎么用?C# PluginFamily.AddInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StructureMap.Graph.PluginFamily的用法示例。


在下文中一共展示了PluginFamily.AddInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindMaster_Instance_happy_path

        public void FindMaster_Instance_happy_path()
        {
            var family = new PluginFamily(typeof (ISomething));
            ObjectInstance redInstance = new ObjectInstance(new SomethingOne()).WithName("Red");
            family.AddInstance(redInstance);
            family.AddInstance(new ObjectInstance(new SomethingOne()).WithName("Blue"));

            var instance = new ReferencedInstance("Red");
            Assert.AreSame(redInstance, ((IDiagnosticInstance) instance).FindInstanceForProfile(family, null, null));
        }
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:10,代码来源:ReferencedInstanceTester.cs

示例2: has_family_but_family_does_not_have_owner

        public void has_family_but_family_does_not_have_owner()
        {
            var family = new PluginFamily(GetType());
            var instance = new SimpleInstance();
            family.AddInstance(instance);

            instance.Owner().ShouldBeNull();
        }
开发者ID:visit,项目名称:structuremap,代码行数:8,代码来源:Instance_finding_its_owner.cs

示例3: 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

示例4: Add_instance_that_does_not_exist_in_destination

        public void Add_instance_that_does_not_exist_in_destination()
        {
            var source = new PluginFamily(typeof (IWidget));
            var sourceInstance = new ObjectInstance(new AWidget());
            source.AddInstance(sourceInstance);

            var destination = new PluginFamily(typeof (IWidget));
            destination.ImportFrom(source);

            Assert.AreSame(sourceInstance, destination.GetInstance(sourceInstance.Name));
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:11,代码来源:PluginFamilyMergeTester.cs

示例5: does_override_the_scope_of_the_parent

        public void does_override_the_scope_of_the_parent()
        {
            var family = new PluginFamily(GetType());
            family.SetScopeTo(InstanceScope.Singleton);

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

            family.AddInstance(i1);

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

示例6: Do_not_override_named_instance

        public void Do_not_override_named_instance()
        {
            var source = new PluginFamily(typeof (IWidget));
            ObjectInstance sourceInstance = new ObjectInstance(new AWidget()).WithName("New");
            source.AddInstance(sourceInstance);

            var destination = new PluginFamily(typeof (IWidget));
            ObjectInstance destinationInstance = new ObjectInstance(new AWidget()).WithName("New");
            destination.AddInstance(destinationInstance);

            destination.ImportFrom(source);

            Assert.AreSame(destinationInstance, destination.GetInstance(sourceInstance.Name));
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:14,代码来源:PluginFamilyMergeTester.cs

示例7: Import_from_family_picks_up_new_instances

        public void Import_from_family_picks_up_new_instances()
        {
            var factory = new InstanceFactory(typeof (IWidget));

            var family = new PluginFamily(typeof (IWidget));
            family.AddInstance(new ObjectInstance(new AWidget()).WithName("New"));
            family.AddInstance(new ObjectInstance(new AWidget()).WithName("New2"));
            family.AddInstance(new ObjectInstance(new AWidget()).WithName("New3"));

            factory.ImportFrom(family);

            Assert.IsNotNull(factory.FindInstance("New"));
            Assert.IsNotNull(factory.FindInstance("New2"));
            Assert.IsNotNull(factory.FindInstance("New3"));
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:15,代码来源:InstanceFactoryTester.cs

示例8: Merge_from_PluginFamily_will_not_replace_an_existing_instance

        public void Merge_from_PluginFamily_will_not_replace_an_existing_instance()
        {
            var factory = new InstanceFactory(typeof (IWidget));
            ObjectInstance instance1 = new ObjectInstance(new AWidget()).WithName("New");
            factory.AddInstance(instance1);

            var family = new PluginFamily(typeof (IWidget));
            family.AddInstance(new ObjectInstance(new AWidget()).WithName("New"));

            factory.ImportFrom(family);

            Assert.AreSame(instance1, factory.FindInstance("New"));
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:13,代码来源:InstanceFactoryTester.cs

示例9: uses_parent_lifecycle_if_none_is_set_on_instance

        public void uses_parent_lifecycle_if_none_is_set_on_instance()
        {
            var family = new PluginFamily(GetType());
            family.SetScopeTo(InstanceScope.Singleton);

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

            family.AddInstance(i1);

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

示例10: attachInstances

 private void attachInstances(PluginFamily family, XmlElement familyElement, IGraphBuilder builder)
 {
     familyElement.ForEachChild(INSTANCE_NODE).Do(element =>
     {
         InstanceMemento memento = _mementoCreator.CreateMemento(element);
         family.AddInstance(memento);
     });
 }
开发者ID:hp4711,项目名称:structuremap,代码行数:8,代码来源:FamilyParser.cs


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