public static void Main(string[] args)
    {
        var registrar = new ContainerRegistrar();

        registrar.RegisterComponents(Lifetime.Transient, Environment.CurrentDirectory, "MyApp.Plugin.*.dll");
        var container = registrar.Build();

        // all extension points have been loaded. To load all menu extensions simply do something like:

        var menu = GetMainMenu();

        foreach (var registrar in container.ResolveAll <IMenuRegistrar>())
        {
            registrar.Register(menu);
        }
    }
        static void Main(string[] args)
        {
            var container = new UnityContainer();

            ContainerRegistrar.Register(container);

            var units = new List <UnitBase>
            {
                container.Resolve <Stone>(),
                container.Resolve <Tractor>(),
                container.Resolve <Wind>()
            };

            units.ExequteOfType <IMovingForward>(unit => unit.MoveForwards());
            units.ExequteOfType <ITurningClockwise>(unit => unit.TurnClockwise());

            var position    = units.OfType <IPositioning>().Select(unit => unit.Position).ToArray();
            var orientation = units.OfType <IOrienting>().Select(unit => unit.Orientation).ToArray();
        }
예제 #3
0
        public static void Main(string[] args)
        {
            var dryIoc = new DryIoc.Container();

            ContainerRegistrar.Register((x, y) => dryIoc.Register(x, y));
            dryIoc.Register <ILogger, ConsoleLogger>();

            var unity = new UnityContainer();

            ContainerRegistrar.Register((x, y) => unity.RegisterType(x, y));
            unity.RegisterType <ILogger, ConsoleLogger>();

            var structureMap = new StructureMap.Container(c => {
                ContainerRegistrar.Register((x, y) => c.For(x).Use(y));
                c.For <ILogger>().Use <ConsoleLogger>();
            });

            var autofac = new Autofac.ContainerBuilder();

            ContainerRegistrar.Register((x, y) => autofac.RegisterType(x).As(y));
            autofac.RegisterType <ILogger>().As <ConsoleLogger>();
        }