Exemple #1
0
 /// <summary>
 /// Enables common service locator and sets the <see cref="IContainer">container</see> as the source of location
 /// </summary>
 /// <param name="configure"><see cref="IConfigure"/> object to configure</param>
 /// <returns>Chained <see cref="IConfigure"/></returns>
 public static IConfigure UsingCommonServiceLocator(this IConfigure configure)
 {
     if (!_configured)
     {
         var serviceLocator = new ContainerServiceLocator(configure.Container);
         configure.Container.Bind <IServiceLocator>(serviceLocator);
         ServiceLocator.SetLocatorProvider(() => serviceLocator);
         _configured = true;
     }
     return(Configure.Instance);
 }
Exemple #2
0
        // Initialize IOC container
        public static void InitializeServiceLocator(Action <IContainer> registerPlatformTypes)
        {
            var container = new Container(GetContainerRules());

            registerPlatformTypes(container);
            RegisterCommonTypes(container);

            var serviceLocator = new ContainerServiceLocator(container);

            ServiceLocator.SetLocatorProvider(() => serviceLocator);
        }
 /// <summary>
 /// Enables common service locator and sets the <see cref="IContainer">container</see> as the source of location
 /// </summary>
 /// <param name="configure"><see cref="IConfigure"/> object to configure</param>
 /// <returns>Chained <see cref="IConfigure"/></returns>
 public static IConfigure UsingCommonServiceLocator(this IConfigure configure)
 {
     if (!_configured)
     {
         var serviceLocator = new ContainerServiceLocator(configure.Container);
         configure.Container.Bind<IServiceLocator>(serviceLocator);
         ServiceLocator.SetLocatorProvider(() => serviceLocator);
         _configured = true;
     }
     return Configure.Instance;
 }
Exemple #4
0
		public App()
		{
			Startup += Application_Startup;
			Exit += Application_Exit;
			UnhandledException += Application_UnhandledException;

            var kernel = new StandardKernel();
            Container = new Container(kernel);
            var serviceLocator = new ContainerServiceLocator(Container);
            Container.Bind<IServiceLocator>(serviceLocator);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);

            var bindings = new DefaultBindings();
            bindings.Initialize(Container);

            var conventions = new DefaultConventions();
            conventions.Initialize();

			InitializeComponent();
		}
Exemple #5
0
#pragma warning restore 1591 // Xml Comments

        void SetupServiceLocator()
        {
            var serviceLocator = new ContainerServiceLocator(Container);
            Container.Bind<IServiceLocator>(serviceLocator);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);
        }