Пример #1
0
 public DbConfiguration(IDbEntityValidator validation,
                        IEntityFilter entityFilter,
                        IAggregateUpdateService aggregateUpdateService,
                        ICacheService cacheService,
                        [CanBeNull] Func <BaseDb> getDbForEvilLazyLoad)
 {
     Validator              = validation;
     EntityFilter           = entityFilter;
     AggregateUpdateService = aggregateUpdateService;
     CacheService           = cacheService;
     GetDbForEvilLazyLoad   = getDbForEvilLazyLoad;
 }
Пример #2
0
        public static void AddConfiguration(
            string entityNameSpace,
            IDbEntityValidator validation = null,
            IEntityFilter entityFilter    = null,
            IAggregateUpdateService aggregateUpdateService = null,
            ICacheService cacheService         = null,
            Func <BaseDb> getDbForEvilLazyLoad = null)
        {
            if (configurationByEntityNamespace.ContainsKey(entityNameSpace))
            {
                throw new InvalidOperationException($"There is already a configuration for '{entityNameSpace}' Changing the configuration is not allowed");
            }

            var configuration = new DbConfiguration(
                validation: validation ?? EmptyValidator.Instance,
                entityFilter: entityFilter ?? EmptyEntityFilter.Instance,
                aggregateUpdateService: aggregateUpdateService ?? EmptyAggregateUpdateService.Instance,
                cacheService: cacheService ?? NullCacheService.Instance,
                getDbForEvilLazyLoad: getDbForEvilLazyLoad
                );

            configurationByEntityNamespace[entityNameSpace] = configuration;
        }