public void set_the_scope_to_session_hybrid() { var family = new PluginFamily(typeof(IServiceProvider)); family.SetScopeTo(WebLifecycles.HybridSession); family.Lifecycle.ShouldBeOfType<HybridSessionLifecycle>(); }
public void SetScopeToHybrid() { var family = new PluginFamily(typeof(IServiceProvider)); family.SetScopeTo(WebLifecycles.Hybrid); family.Lifecycle.ShouldBeOfType<HybridLifecycle>(); }
public void SetScopeToHttpContext() { var family = new PluginFamily(typeof(IServiceProvider)); family.Lifecycle.ShouldBeOfType<TransientLifecycle>(); family.SetScopeTo(WebLifecycles.HttpContext); family.Lifecycle.ShouldBeOfType<HttpContextLifecycle>(); }
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>(); }
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>(); }
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); }
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>(); }
public void Configure(PluginFamily family) { if (Scope != InstanceScope.Transient) family.SetScopeTo(Scope); }
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)); }); }