本文整理匯總了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);
});
}