예제 #1
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Initialises this object.
        /// </summary>
        ///-------------------------------------------------------------------------------------------------

        public static void Init()
        {
            EntityContextFactory.Initalize();
            Container.Bind <IUnitOfWork>().ToMethod(
                () =>
            {
                string nameOrConnectionString  = null;
                var overriddenConnectionString = WebConfigurationManager.AppSettings["Framework.RepositoryContext"];
                if (!string.IsNullOrWhiteSpace(overriddenConnectionString))
                {
                    nameOrConnectionString = overriddenConnectionString;
                }

                if (string.IsNullOrWhiteSpace(nameOrConnectionString))
                {
                    nameOrConnectionString = "AppContext";
                }

                return(new UnitOfWork(nameOrConnectionString));
            }).InRequestScope();
        }