Exemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            new UnhandledExceptionHook(this);

            Application.Current.Exit += OnShutdown;

            myComposer = new Composer();
            myComposer.Add(new AssemblyCatalog(GetType().Assembly));

            myComposer.Compose();

            Application.Current.MainWindow = myComposer.Resolve <Shell>();
            Application.Current.MainWindow.Show();
        }
Exemplo n.º 2
0
        public void Compose_DecoratorGiven_DecoratedInstanceIsImported()
        {
            var composer = new Composer();

            composer.Register(typeof(User));

            var decoration = new DecoratorChainCatalog(typeof(IContract));

            decoration.Add(typeof(Impl));
            decoration.Add(typeof(Decorator1));
            decoration.Add(typeof(Decorator2));

            composer.Add(decoration);

            composer.Compose();

            var user = composer.Resolve <User>();

            Assert.That(user.Contract, Is.InstanceOf <Decorator2>());
        }