Ejemplo n.º 1
0
        static ApiSetup()
        {
            try
            {
                //Create
                Container = new UnityContainer();
                Locator   = new UnityServiceLocator(Container);
                //Add entlib extensions
                Container.AddNewExtension <EnterpriseLibraryCoreExtension>();
#pragma warning disable 612,618
                Container.AddNewExtension <CachingBlockExtension>();
#pragma warning restore 612,618
                ServiceLocator.SetLocatorProvider(() => Locator);
                Container.LoadConfiguration("api");
                ApiDefaultConfig.DoDefaultRegistrations(Container);
                //NOTE: disabled for now
                //try
                //{
                //    ApiDefaultConfig.DoAutomaticConfiguration(Container);
                //    Initialization.Add(ApiSetupState.UnityAutoRegitrations, null);
                //}
                //catch (Exception e)
                //{
                //    Initialization.Add(ApiSetupState.UnityAutoRegitrations, new[] { e });
                //}
            }
            catch (Exception e)
            {
                Initialization.Add(ApiSetupState.UnityRegitrations, new[] { e });
                throw;
            }
            Initialization.Add(ApiSetupState.UnityRegitrations, null);
        }
Ejemplo n.º 2
0
        private static void Init()
        {
            if (!initialized)
            {
                lock (locker)
                {
                    if (!initialized)
                    {
                        Container = new UnityContainer();
                        locator   = new UnityServiceLocator(Container);

                        ServiceLocator.SetLocatorProvider(() => locator);
                        Container.LoadConfiguration("api");
                        ApiDefaultConfig.DoDefaultRegistrations(Container);

                        initialized = true;
                    }
                }
            }
        }