本文整理汇总了C#中StructureMap.Graph.PluginFamily.SetScopeTo方法的典型用法代码示例。如果您正苦于以下问题:C# PluginFamily.SetScopeTo方法的具体用法?C# PluginFamily.SetScopeTo怎么用?C# PluginFamily.SetScopeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StructureMap.Graph.PluginFamily
的用法示例。
在下文中一共展示了PluginFamily.SetScopeTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: set_the_scope_to_session_hybrid
public void set_the_scope_to_session_hybrid()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.SetScopeTo(WebLifecycles.HybridSession);
family.Lifecycle.ShouldBeOfType<HybridSessionLifecycle>();
}
示例2: SetScopeToHybrid
public void SetScopeToHybrid()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.SetScopeTo(WebLifecycles.Hybrid);
family.Lifecycle.ShouldBeOfType<HybridLifecycle>();
}
示例3: SetScopeToHttpContext
public void SetScopeToHttpContext()
{
var family = new PluginFamily(typeof(IServiceProvider));
family.Lifecycle.ShouldBeOfType<TransientLifecycle>();
family.SetScopeTo(WebLifecycles.HttpContext);
family.Lifecycle.ShouldBeOfType<HttpContextLifecycle>();
}
示例4: 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>();
}
示例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_replace_the_build_Lifecycle_if_it_is_the_same_type_as_the_imported_family
public void do_not_replace_the_build_Lifecycle_if_it_is_the_same_type_as_the_imported_family()
{
var originalFamily = new PluginFamily(typeof (IWidget));
originalFamily.SetScopeTo(InstanceScope.Singleton);
var factory = new InstanceFactory(originalFamily);
ILifecycle originalLifecycle = factory.Lifecycle;
var family = new PluginFamily(typeof (IWidget));
family.SetScopeTo(InstanceScope.Singleton);
factory.ImportFrom(family);
factory.Lifecycle.ShouldBeTheSameAs(originalLifecycle);
}
示例7: 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>();
}
示例8: Configure
public void Configure(PluginFamily family)
{
if (Scope != InstanceScope.Transient) family.SetScopeTo(Scope);
}
示例9: attachInterceptors
private void attachInterceptors(PluginFamily family, XmlElement familyElement)
{
string contextBase = string.Format("creating an InstanceInterceptor for {0}\n",
family.PluginType.AssemblyQualifiedName);
familyElement.ForEachChild("*/Interceptor").Do(element =>
{
var interceptorMemento = new XmlAttributeInstanceMemento(element);
string context = contextBase + element.OuterXml;
_builder.WithSystemObject<ILifecycle>(
interceptorMemento,
context,
lifecycle => family.SetScopeTo(lifecycle));
});
}