本文整理汇总了C#中StructureMap.Graph.PluginFamily类的典型用法代码示例。如果您正苦于以下问题:C# PluginFamily类的具体用法?C# PluginFamily怎么用?C# PluginFamily使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginFamily类属于StructureMap.Graph命名空间,在下文中一共展示了PluginFamily类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetScopeToHybrid
public void SetScopeToHybrid()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.SetLifecycleTo(WebLifecycles.Hybrid);
family.Lifecycle.ShouldBeOfType<HybridLifecycle>();
}
开发者ID:joelweiss,项目名称:structuremap,代码行数:7,代码来源:PluginFamilyTester.cs
示例2: validateInstance
private void validateInstance(IDiagnosticInstance instance, PluginFamily family, PluginGraph graph)
{
if (!instance.CanBePartOfPluginFamily(family))
{
graph.Log.RegisterError(104, instance.CreateToken(), family.PluginType);
}
}
开发者ID:satish860,项目名称:StructureMap3,代码行数:7,代码来源:ValidatePluggabilityPolicy.cs
示例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>();
}
开发者ID:joelweiss,项目名称:structuremap,代码行数:7,代码来源:PluginFamilyTester.cs
示例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();
}
开发者ID:smerrell,项目名称:structuremap,代码行数:7,代码来源:ConfiguredInstanceTester.cs
示例5: SetUp
public void SetUp()
{
family = new PluginFamily(typeof (IService<>));
PluginGraph.CreateRoot("something").AddFamily(family);
configuration = new GenericFamilyConfiguration(family, PipelineGraph.BuildEmpty());
}
开发者ID:slahn,项目名称:structuremap,代码行数:7,代码来源:GenericFamilyConfigurationTester.cs
示例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);
}
}
开发者ID:hp4711,项目名称:structuremap,代码行数:29,代码来源:InstanceFactory.cs
示例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());
}
开发者ID:goraw,项目名称:structuremap,代码行数:26,代码来源:CloseGenericFamilyPolicy.cs
示例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);
});
}
开发者ID:hp4711,项目名称:structuremap,代码行数:8,代码来源:FamilyParser.cs
示例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));
}
开发者ID:hp4711,项目名称:structuremap,代码行数:8,代码来源:MementoTester.cs
示例10: SetScopeToHttpContext
public void SetScopeToHttpContext()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.Lifecycle.ShouldBeNull();
family.SetLifecycleTo(WebLifecycles.HttpContext);
family.Lifecycle.ShouldBeOfType<HttpContextLifecycle>();
}
开发者ID:joelweiss,项目名称:structuremap,代码行数:8,代码来源:PluginFamilyTester.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: 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
示例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;
}
开发者ID:slahn,项目名称:structuremap,代码行数:9,代码来源:try_get_instance.cs
示例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));
}
开发者ID:joshuaflanagan,项目名称:structuremap,代码行数:10,代码来源:ReferencedInstanceTester.cs
示例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>();
}
开发者ID:smerrell,项目名称:structuremap,代码行数:10,代码来源:InstanceTester.cs
示例16: assertScopeLeadsToInterceptor
private void assertScopeLeadsToInterceptor(string scope, Type interceptorType)
{
var att = new PluginFamilyAttribute();
att.Scope = scope;
var family = new PluginFamily(typeof (TypeThatDoesNotHaveCustomMementoSource));
att.Configure(family);
family.Lifecycle.ShouldBeOfType(interceptorType);
}
开发者ID:smerrell,项目名称:structuremap,代码行数:10,代码来源:PluginFamilyAttributeTester.cs
示例17: import_from_another_family_will_override_the_build_policy_if_the_initial_policy_is_the_default
public void import_from_another_family_will_override_the_build_policy_if_the_initial_policy_is_the_default()
{
var factory = new InstanceFactory(typeof (IWidget));
var family = new PluginFamily(typeof (IWidget));
family.SetScopeTo(InstanceScope.Singleton);
factory.ImportFrom(family);
factory.Lifecycle.ShouldBeOfType<SingletonLifecycle>();
}
开发者ID:satish860,项目名称:StructureMap3,代码行数:11,代码来源:InstanceFactoryTester.cs
示例18: ConfigureFamily
public static void ConfigureFamily(PluginFamily family)
{
var att =
GetCustomAttribute(family.PluginType, typeof (PluginFamilyAttribute), false)
as PluginFamilyAttribute;
if (att != null)
{
att.Configure(family);
}
}
开发者ID:smerrell,项目名称:structuremap,代码行数:11,代码来源:PluginFamilyAttribute.cs
示例19: 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
示例20: does_override_the_scope_of_the_parent
public void does_override_the_scope_of_the_parent()
{
var family = new PluginFamily(GetType());
family.SetLifecycleTo(Lifecycles.Singleton);
var i1 = new ConfiguredInstance(GetType()).Named("foo");
i1.SetLifecycleTo(Lifecycles.ThreadLocal);
family.AddInstance(i1);
i1.Lifecycle.ShouldBeOfType<ThreadLocalStorageLifecycle>();
}
开发者ID:e-tobi,项目名称:structuremap,代码行数:12,代码来源:InstanceTester.cs
注:本文中的StructureMap.Graph.PluginFamily类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论