public void set_to_singleton()
        {
            // SAMPLE: set-iconfigured-instance-to-SingletonThing
            IConfiguredInstance instance 
                = new ConfiguredInstance(typeof (WidgetHolder));

            instance.Singleton();

            instance.Lifecycle.ShouldBeOfType<SingletonLifecycle>();
            // ENDSAMPLE
        }
Ejemplo n.º 2
0
        public void Modify()
        {
            IConfiguredInstance instance = 
                new ConfiguredInstance(typeof(ImportantService));


            instance.SetLifecycleTo(new SingletonLifecycle());

            instance.SetLifecycleTo<SingletonLifecycle>();

            instance.Singleton();


        } 
        public void set_to_default()
        {
            
            // SAMPLE: iconfiguredinstance-lifecycle
            IConfiguredInstance instance
                = new ConfiguredInstance(typeof(WidgetHolder));

            // Use the SingletonThing lifecycle
            instance.Singleton();

            // or supply an ILifecycle type
            instance.SetLifecycleTo<HttpContextLifecycle>();

            // or supply an ILifecycle object
            instance.SetLifecycleTo(new Lifecycles_Samples.MyCustomLifecycle());

            // or override to the default "transient" lifecycle
            instance.DefaultLifecycle();
            // ENDSAMPLE

            instance.Lifecycle
                .ShouldBeOfType<TransientLifecycle>();

        }