Ejemplo n.º 1
0
        // The MixinConfiguration is passed to Execute in order to be able to call PrepareOutputDirectory before analyzing the configuration (and potentially
        // locking old generated files).
        public void Execute(MixinConfiguration configuration)
        {
            ArgumentUtility.CheckNotNull("configuration", configuration);

            using (StopwatchScope.CreateScope(s_log, LogLevel.Info, "Time needed to mix and save all types: {elapsed}."))
            {
                _errors.Clear();
                _processedTypes.Clear();
                _finishedTypes.Clear();
                _generatedFiles = new string[0].AsReadOnly();

                s_log.InfoFormat("The base directory is '{0}'.", AppDomain.CurrentDomain.BaseDirectory);

                var pipeline = MixerPipelineFactory.CreatePipeline(AssemblyOutputDirectory);

                var mixedTypes = MixedTypeFinder.FindMixedTypes(configuration).ToArray();

                s_log.Info("Generating types...");
                using (configuration.EnterScope())
                {
                    foreach (var mixedType in mixedTypes)
                    {
                        Generate(mixedType, pipeline);
                    }
                }

                s_log.Info("Saving assemblies...");
                Save(pipeline);
            }

            s_log.InfoFormat("Successfully generated concrete types for {0} target classes.", _finishedTypes.Count);
        }
Ejemplo n.º 2
0
        public static Mixer Create(string assemblyName, string assemblyOutputDirectory, int degreeOfParallelism)
        {
            var builderFactory = new MixerPipelineFactory(assemblyName, degreeOfParallelism);

            // Use a custom TypeDiscoveryService with the LoadAllAssemblyLoaderFilter so that mixed types within system assemblies are also considered.
            var assemblyLoader       = new FilteringAssemblyLoader(new LoadAllAssemblyLoaderFilter());
            var rootAssemblyFinder   = SearchPathRootAssemblyFinder.CreateForCurrentAppDomain(false, assemblyLoader);
            var assemblyFinder       = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            var typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

            var finder = new MixedTypeFinder(typeDiscoveryService);

            return(new Mixer(finder, builderFactory, assemblyOutputDirectory));
        }