Ejemplo n.º 1
0
        protected TestBase()
        {
            var kernelBuilder = new KernelBuilder();
            kernelBuilder.OnStarting(Register);
            kernelBuilder.UseCaching(c => c.UseMemoryCache());
            kernelBuilder.UseLogging(c => c.UseNLog());

            var container = Container = kernelBuilder.Build();
            var type = GetType();
            var properties = type.GetProperties();
            foreach (var property in properties)
            {
                var propertyType = property.PropertyType;
                if (!container.IsRegistered(propertyType))
                    continue;
                property.SetValue(this, container.Resolve(propertyType), null);
            }
        }
Ejemplo n.º 2
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var kernelBuilder = new KernelBuilder();

            kernelBuilder.OnStarting(builder => builder.RegisterType <MainForm>().AsSelf().As <IUserInterfaceController>().InstancePerLifetimeScope());
            kernelBuilder.UseCaching(c => c.UseMemoryCache());

            var hostContainer = kernelBuilder.Build();
            var host          = hostContainer.Resolve <IHost>();

            host.Initialize();

            var work = host.CreateStandaloneEnvironment(new ShellSettings {
                Name = "Default"
            });
            var form = work.Resolve <MainForm>();

            Application.Run(form);
        }
Ejemplo n.º 3
0
        protected TestBase()
        {
            var kernelBuilder = new KernelBuilder();

            kernelBuilder.OnStarting(Register);
            kernelBuilder.UseCaching(c => c.UseMemoryCache());
            //.UseLogging(c => c.UseNLog());

            var container  = Container = kernelBuilder.Build();
            var type       = GetType();
            var properties = type.GetProperties();

            foreach (var property in properties)
            {
                var propertyType = property.PropertyType;
                if (!container.IsRegistered(propertyType))
                {
                    continue;
                }
                property.SetValue(this, container.Resolve(propertyType), null);
            }
        }