Example #1
0
        //---------------------------------------------------
        //private

        private static void SetupDtoMapping(Type dtoType, NonDiBizSetup nonDiConf)
        {
            var bizIn = dtoType.GetInterface(nameof(IGenericActionToBizDto)) != null;

            if (!bizIn && dtoType.GetInterface(nameof(IGenericActionFromBizDto)) == null)
            {
                throw new InvalidOperationException($"The class {dtoType.Name} doesn't inherit from one of the Biz Runner Dto classes.");
            }

            SetupDtoMappings.SetupGenericActionMappingForDto(dtoType, bizIn ? nonDiConf._bizInProfile : nonDiConf._bizOutProfile, bizIn);
        }
Example #2
0
        //---------------------------------------------------------
        //private parts

        private static void BuildRegisterWrappedConfig(this IServiceCollection services,
                                                       IGenericBizRunnerConfig config, params Assembly[] assembliesToScan)
        {
            //It is possible that the user would use both default DbContext and MultiDbContext, so we only add if not already there
            if (!services.Contains(
                    new ServiceDescriptor(typeof(IWrappedBizRunnerConfigAndMappings), config), new CheckDescriptor()))
            {
                var wrapBuilder   = new SetupDtoMappings(config);
                var wrapperConfig = wrapBuilder.BuildWrappedConfigByScanningForDtos(assembliesToScan.Distinct().ToArray(), config);
                //Register the IWrappedBizRunnerConfigAndMappings
                services.AddSingleton(wrapperConfig);
            }
        }