예제 #1
0
        public static IUnityContainer Configure()
        {
            var currentUser = new IdentityUser();

            IUnityContainer container = new UnityContainer();

            UnityBusinessConfigure.Using <IAuthenticationProcess>(container)
            .ConfigureNCommon(c => UnityDefaultNCommonConfig.GetEFWithTransaction <LicenseContext, DbContext>(c, currentUser,
                                                                                                              () => new LicenseContext())) //Устанавливаем NCommon
            //.ConfigureSingletonParameter(GetLogger())
            .BuildConfiguration();

            return(container);
        }
예제 #2
0
        public static IProcess Configure <TTemplateData>(string sourcePath, string templatePath, string outPath) where TTemplateData : class, new()
        {
            Guard.AssertNotEmpty(sourcePath, "Не определен путь источника");
            Guard.AssertNotEmpty(templatePath, "Не определен пусть к шаблону");

            IUnityContainer container = new UnityContainer();

            UnityBusinessConfigure.Using <IProcess>(container)
            //.ConfigureOperation<ISourceRepository<TTemplateData>, ExcelSourceRepository<TTemplateData>>(new ConstructorParameterCollection().Add("sourcePath", sourcePath))
            .ConfigureOperation <IDataEnumerator <TTemplateData>, ExcelSourceEnumerator <TTemplateData> >(new ConstructorParameterCollection().Add("sourcePath", sourcePath))
            .ConfigureSingletonParameter <Logger>(LogManager.GetLogger("DocumentGeneration"))
            //.RegisterInstance<IEmitRepository>(new WordEmitRepository())
            //.RegisterType<IEmitRepository, WordEmitRepository>(new InjectionConstructor(new InjectionParameter(templatePath)))
            .ConfigureOperation <IEmitRepository, WordEmitRepository>()
            .ConfigureOperation <IFormatter, DefaultFormatter>()
            .ConfigureOperation <IFormatter, DefaultFormatter>("Default")
            .ConfigureOperation <IFormatter, AppointmentDeclensionFormatter>("AppointmentDeclension")
            .ConfigureOperation <IFormatter, PersonNameFormatter>("PersonName")
            .ConfigureOperation <IFormatter, WelcomeFormatter>("Welcome")
            .ConfigureOperation <IFormatter, PersonTotalNameDeclensionFormatter>("PersonTotalNameDeclension")
            .ConfigureOperation <IDictionary <FilterType, IFormatter>, Dictionary <FilterType, IFormatter> >(c => new Dictionary <FilterType, IFormatter>()
            {
                { FilterType.None, c.Resolve <IFormatter>("Default") }
#if (Basis || Pro || DEBUG)
                , { FilterType.PersonDeclension, c.Resolve <IFormatter>("PersonTotalNameDeclension") },
                { FilterType.OnlyPersonName, c.Resolve <IFormatter>("PersonName") },
                { FilterType.AppointmentDeclension, c.Resolve <IFormatter>("AppointmentDeclension") },
                { FilterType.Welcome, c.Resolve <IFormatter>("Welcome") }
#endif
            })
            .ConfigureOperation <IFormatterFactory, FormatterFactory>()
            .ConfigureOperation <IDeclension, Declension>()
            .ConfigureOperation <IGenerator <TTemplateData>, Generator <TTemplateData> >(                             //new InjectionConstructor(new ResolvedParameter<IEmitRepository>(), new InjectionParameter(outPath), new InjectionParameter(templatePath), new ResolvedParameter<IFormatterFactory>()))
                new ConstructorParameterCollection().Add("paths", new Tuple <string, string>(outPath, templatePath))) //.Add("templatePath", templatePath).Add("outPath", outPath))
            //.ConfigureProcess<IProcess, Process<TTemplateData>>(c => new Process<TTemplateData>(c.Resolve<Logger>(), c.Resolve<ISourceRepository<TTemplateData>>(), () => c.Resolve<IGenerator<TTemplateData>>(), c.Resolve<IEmitRepository>()))
            .ConfigureProcess <IProcess, Process <TTemplateData> >(c => new Process <TTemplateData>(c.Resolve <Logger>(), () => { lock (c) return(c.Resolve <IGenerator <TTemplateData> >()); }
                                                                                                    , c.Resolve <IDataEnumerator <TTemplateData> >(), c.Resolve <IEmitRepository>())
                                                                   )
            .BuildConfiguration();         //new InjectionFactory(c=>new Process<TTemplateData>(c.Resolve<Logger>(), c.Resolve<ISourceRepository<TTemplateData>>(), ()=>c.Resolve<IGenerator<TTemplateData>>(), c.Resolve<IEmitRepository>()))
            //.RegisterType<IProcess, Process<TTemplateData>>();
            return(container.Resolve <IProcess>());
        }
예제 #3
0
        public static IAuthenticationProcess Configure(IUnityContainer rootContainer = null, bool isDegugMode = false)
        {
            //Guard.AssertNotEmpty(sourcePath, "Не определен путь источника");

            var currentUser = new IdentityUser();
            var config      = new AuthenticationConfiguration()
            {
                DebugMode = isDegugMode
            };

            IUnityContainer container = rootContainer == null ? new UnityContainer() : rootContainer.CreateChildContainer();

            UnityBusinessConfigure.Using <IAuthenticationProcess>(container)
            .ConfigureNCommon(c => UnityDefaultNCommonConfig.GetEFWithTransaction <LicenseContext, DbContext>(c, currentUser,
                                                                                                              () => new LicenseContext())) //Устанавливаем NCommon
            .ConfigureSingletonParameter(GetLogger())
            .ConfigureSingletonParameter <IAuthenticationConfiguration>(config)
            .ConfigureOperation <IAccountRepository, AccountRepository>()
            .ConfigureOperation <ILogonHistoryRepository, LogonHistoryRepository>()
            .ConfigureProcess <IAuthenticationProcess, AuthenticationProcess>()
            .BuildConfiguration();

            return(container.Resolve <IAuthenticationProcess>());
        }