本文整理汇总了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));
}
示例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();
}
示例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>();
}
示例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));
}
示例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>();
}
示例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));
}
示例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"));
}
示例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"));
}
示例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>();
}
示例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);
});
}