Example #1
0
        private void Register(bool withEvents = false)
        {
            //Queries and Commands
            //Register(typeof(IQuery<>), typeof(QueryProcessor).Assembly);
            Register(typeof(IQueryHandler <,>), typeof(QueryProcessor).Assembly, typeof(TypiconEntityModel).Assembly);
            Register <IQueryProcessor, DataQueryProcessor>();

            Register(typeof(ICommandHandler <>), typeof(CommandProcessor).Assembly, typeof(MajorDataCalculator).Assembly);

            RegisterConditional <ICommandProcessor, AsyncCommandProcessor>(
                c => c.Consumer.ImplementationType == typeof(JobExecutor));
            RegisterConditional <ICommandProcessor, CommandProcessor>(c => !c.Handled);

            //OutputForms
            Register <IRuleHandlerSettingsFactory, RuleHandlerSettingsFactory>();
            Register <IScheduleDayNameComposer, ScheduleDayNameComposer>();
            Register <IRuleSerializerRoot, RuleSerializerRoot>();
            Register <ITypiconSerializer, TypiconSerializer>();
            //Для TypiconVariables
            Register <VariablesCollectorSerializerRoot>();

            //Register<IOutputForms, OutputForms>();
            Register <IOutputDayFactory, OutputDayFactory>();
            Register <IScheduleDayViewer <string>, HtmlScheduleDayViewer>();
            Register <IScheduleWeekViewer <string>, TextScheduleWeekViewer>();
            Register <IScheduleWeekViewer <Result <FileDownloadResponse> >, DocxToStreamWeekViewer>();

            Register <ITypiconExportManager, TypiconXmlExportManager>();
            Register <ITypiconImportManager, TypiconXmlImportManager>();
            Register <IProjector <TypiconVersion, TypiconVersionProjection>, TypiconExportProjector>();
            Register <IProjector <TypiconVersionProjection, TypiconEntity>, TypiconImportProjector>();

            //регистрируем просто ScheduleHandler - будет формировать только расписание, без последовательностей
            //но зато повыситься производительность
            Register <ScheduleHandler, ServiceSequenceHandler>();
            //Register<ScheduleHandler>();

            ////Все контроллеры
            Register <IScheduleDataCalculator, MajorDataCalculator>();

            RegisterDecorator(
                typeof(IScheduleDataCalculator),
                typeof(TransparentDataCalculator));

            RegisterDecorator(
                typeof(IScheduleDataCalculator),
                typeof(AsAdditionDataCalculator));

            RegisterDecorator(
                typeof(IScheduleDataCalculator),
                typeof(ExplicitDataCalculator));

            //CustomSequence Controller
            Register <CustomScheduleDataCalculator>();

            RegisterSingleton <IJobRepository>(() => new JobRepository());

            /*
             * DbContexts
             */
            RegisterInstance((withEvents)
                ? TypiconDbContextFactory.CreateWithEvents()
                : TypiconDbContextFactory.Create());

            RegisterInstance(WebDbContextFactory.Create());

            /*
             * Events
             */
            Register <IEventDispatcher, DomainEventDispatcher>();

            var assemblies = new[] { typeof(DomainEventDispatcher).Assembly };

            Collection.Register(typeof(IDomainEventHandler <>), assemblies);
        }
 public static IUnitOfWork Create()
 {
     return(Create(TypiconDbContextFactory.Create()));
 }
Example #3
0
 public static ICommandProcessor Create() => Create(TypiconDbContextFactory.Create());
 public static ScheduleService Create() => Create(TypiconDbContextFactory.Create());
 public static IQueryProcessor Create() => Create(TypiconDbContextFactory.Create());
 public static CollectorSerializerRoot CreateCollectorSerializerRoot() => CreateCollectorSerializerRoot(TypiconDbContextFactory.Create());
 public static IRuleSerializerRoot Create() => Create(TypiconDbContextFactory.Create());