示例#1
0
        public Generator()
        {
            Logger.CatchAll();
            Logger.Trace($"KY Generator v{Assembly.GetCallingAssembly().GetName().Version}");
            Logger.Trace("Current Directory: " + Environment.CurrentDirectory);
            Logger.Trace("Log Directory: " + Logger.File.Path);

            NugetPackageDependencyLoader.Activate();

            this.output   = new FileOutput(AppDomain.CurrentDomain.BaseDirectory);
            this.resolver = new DependencyResolver();
            this.resolver.Bind <ITypeMapping>().ToSingleton <TypeMapping>();
            this.resolver.Bind <CommandRunner>().ToSelf();
            this.resolver.Bind <ModuleFinder>().ToSelf();
            this.resolver.Bind <IConfigurationReaderVersion>().To <ConfigurationReaderVersion2>();
            this.resolver.Bind <ReaderConfigurationMapping>().ToSingleton();
            this.resolver.Bind <WriterConfigurationMapping>().ToSingleton();
            this.resolver.Bind <ConfigurationRunner>().ToSelf();
            this.resolver.Bind <ModelWriter>().ToSelf();
            StaticResolver.Resolver = this.resolver;

            ModuleFinder moduleFinder = this.resolver.Get <ModuleFinder>();

            moduleFinder.LoadFromAssemblies();
            this.Modules = moduleFinder.Modules;
            foreach (ModuleBase module in this.Modules)
            {
                Logger.Trace($"{module.GetType().Name.Replace("Module", "")}-{module.GetType().Assembly.GetName().Version} module loaded");
            }
            this.Modules.ForEach(module => this.resolver.Bind <ModuleBase>().To(module));
            this.Modules.ForEach(module => module.Initialize());
        }
示例#2
0
        public static bool Run(string[] args)
        {
#if DEBUG
            if (args.Length > 0 && args[0] != "statistics")
            {
                System.Diagnostics.Debugger.Launch();
            }
#endif
            Generator.InitializeLogger(args);
            NugetPackageDependencyLoader.Activate();
            NugetPackageDependencyLoader.Locations.Insert(0, new SearchLocation(SharedPath));
            return(Generator.Initialize()
                   .PreloadModules(SharedPath, "KY.Generator.*.dll")
                   .SetParameters(args)
                   .Run());
        }