本文整理汇总了C#中StructureMap.Graph.PluginFamily类的典型用法代码示例。如果您正苦于以下问题:C# PluginFamily类的具体用法?C# PluginFamily怎么用?C# PluginFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginFamily类属于StructureMap.Graph命名空间,在下文中一共展示了PluginFamily类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetScopeToHybrid
public void SetScopeToHybrid()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.SetLifecycleTo(WebLifecycles.Hybrid);
family.Lifecycle.ShouldBeOfType<HybridLifecycle>();
}
示例2: validateInstance
private void validateInstance(IDiagnosticInstance instance, PluginFamily family, PluginGraph graph)
{
if (!instance.CanBePartOfPluginFamily(family))
{
graph.Log.RegisterError(104, instance.CreateToken(), family.PluginType);
}
}
示例3: set_the_scope_to_session_hybrid
public void set_the_scope_to_session_hybrid()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.SetLifecycleTo(WebLifecycles.HybridSession);
family.Lifecycle.ShouldBeOfType<HybridSessionLifecycle>();
}
示例4: 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();
}
示例5: SetUp
public void SetUp()
{
family = new PluginFamily(typeof (IService<>));
PluginGraph.CreateRoot("something").AddFamily(family);
configuration = new GenericFamilyConfiguration(family, PipelineGraph.BuildEmpty());
}
示例6: InstanceFactory
/// <summary>
/// Constructor to use when troubleshooting possible configuration issues.
/// </summary>
/// <param name="family"></param>
public InstanceFactory(PluginFamily family)
{
if (family == null)
{
throw new ArgumentNullException("family");
}
try
{
_lifecycle = family.Lifecycle;
_pluginType = family.PluginType;
MissingInstance = family.MissingInstance;
family.Instances.Each(AddInstance);
}
catch (StructureMapException)
{
throw;
}
catch (Exception e)
{
throw new StructureMapException(115, e, family.PluginType.AssemblyQualifiedName);
}
}
示例7: Build
public PluginFamily Build(Type type)
{
if (!type.GetTypeInfo().IsGenericType) return null;
var basicType = type.GetGenericTypeDefinition();
if (!_graph.Families.Has(basicType))
{
// RIGHT HERE: do the connections thing HERE!
var connectingTypes = _graph.ConnectedConcretions.Where(x => x.CanBeCastTo(type)).ToArray();
if (connectingTypes.Any())
{
var family = new PluginFamily(type);
connectingTypes.Each(family.AddType);
return family;
}
return _graph.Families.ToArray().FirstOrDefault(x => type.GetTypeInfo().IsAssignableFrom(x.PluginType.GetTypeInfo()));
}
var basicFamily = _graph.Families[basicType];
var templatedParameterTypes = type.GetGenericArguments();
return basicFamily.CreateTemplatedClone(templatedParameterTypes.ToArray());
}
示例8: attachInstances
private void attachInstances(PluginFamily family, XmlElement familyElement, IGraphBuilder builder)
{
familyElement.ForEachChild(INSTANCE_NODE).Do(element =>
{
InstanceMemento memento = _mementoCreator.CreateMemento(element);
family.AddInstance(memento);
});
}
示例9: If_a_Memento_does_not_know_its_PluggedType_or_concreteKey_select_the_DEFAULT_Plugin
public void If_a_Memento_does_not_know_its_PluggedType_or_concreteKey_select_the_DEFAULT_Plugin()
{
var family = new PluginFamily(typeof (IGateway));
Plugin plugin = family.AddPlugin(typeof (TheGateway), Plugin.DEFAULT);
var memento = new MemoryInstanceMemento();
Assert.AreSame(plugin, memento.FindPlugin(family));
}
示例10: SetScopeToHttpContext
public void SetScopeToHttpContext()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.Lifecycle.ShouldBeNull();
family.SetLifecycleTo(WebLifecycles.HttpContext);
family.Lifecycle.ShouldBeOfType<HttpContextLifecycle>();
}
示例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));
}
示例12: 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();
}
示例13: Build
public PluginFamily Build(Type type)
{
if (type != typeof (IFancy)) return null;
var family = new PluginFamily(type);
family.SetDefault(new SmartInstance<Very>());
return family;
}
示例14: 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));
}
示例15: 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>();
}