CQRSalad.EventSourcing.ApplicationServiceGenerator.Generate C# (CSharp) Метод

Generate() публичный статический Метод

public static Generate ( Assembly assemblyWithAggregates ) : Assembly
assemblyWithAggregates System.Reflection.Assembly
Результат System.Reflection.Assembly
        public static Assembly Generate(Assembly assemblyWithAggregates)
        {
            Argument.IsNotNull(assemblyWithAggregates, nameof(assemblyWithAggregates));

            List<Type> aggregateTypes = GetAggregateTypes(assemblyWithAggregates);
            string[] classSources = aggregateTypes.Select(x => new ApplicationServiceTemplate().Compile(x)).ToArray();
            
            string[] referencedAssemblies = AppDomain.CurrentDomain.GetAssemblies()
                                                     .Where(a => !a.FullName.StartsWith("mscorlib", StringComparison.InvariantCultureIgnoreCase))
                                                     .Where(a => !a.IsDynamic)
                                                     .Select(a => a.Location)
                                                     .ToArray();

            var compilerParams = new CompilerParameters(referencedAssemblies) { GenerateInMemory = true };

            var providerOptions = new Dictionary<string, string> { { "CompilerVersion", "v4.0" } };
            var provider = new CSharpCodeProvider(providerOptions);
            CompilerResults results = provider.CompileAssemblyFromSource(compilerParams, classSources);
            return results.CompiledAssembly;
        }
ApplicationServiceGenerator