Пример #1
0
        private Task <ConcurrentBag <string> > RunGenerator(IGenerator[]?generators = null, bool shareGlobalWriters = false)
        {
            generators ??= new[] { this.generator };
            var generatorSetups = generators.ConvertAll(x =>
                                                        new GeneratorSetup(new TypeOrObject <IGenerator>(x), null, false, shareGlobalWriters));

            return(GeneratorFacade.RunAsync(
                       new GeneratorOptions {
                ProgressReporter = this.progressReporter
            },
                       new Setup(
                           new ModelSetup(new TypeOrObject <IModelProvider>(this.modelProvider), typeof(object)),
                           new[] { new WriterSetup("AnyTarget", new TypeOrObject <IWriter>(this.writer)) },
                           generatorSetups !)));
        }
Пример #2
0
 public static Task Main()
 {
     return(GeneratorFacade.RunAsync(new CodeSetup
     {
         ModelSetup = new FolderModelSetup
         {
             Folder = "../../../Models",
             FilesSearchPattern = "*.json",
         },
         WriterSetups = new[]
         {
             new FileWriterSetup("../../../../Sundew.Quantities/Sundew.Quantities.csproj")
             {
                 Writer = new ProjectTextFileWriter(),
                 FileExtension = ".cs",
                 FileNameSuffix = ".g",
                 Folder = ".generated",
             },
         },
         TargetNamespace = "UnitSelectors",
         UseGlobalUsings = true,
         Usings = new[] { "System.CodeDom.Compiler" },
         GeneratorSetups = new[]
         {
             new CodeGeneratorSetup
             {
                 Generator = new UnitSelectorGenerator(),
                 Usings = new []
                 {
                     "System.Collections.Generic",
                     "Sundew.Quantities.Representations.Units",
                     "Sundew.Quantities.Representations.Expressions",
                     "Sundew.Quantities.UnitSelection"
                 },
             },
             new CodeGeneratorSetup
             {
                 Generator = new UnitSelectorInterfaceGenerator(),
                 Usings = new []
                 {
                     "Sundew.Quantities.Representations.Units",
                     "Sundew.Quantities.Representations.Expressions",
                     "Sundew.Quantities.UnitSelection"
                 },
             },
             new CodeGeneratorSetup
             {
                 Generator = new PrefixedUnitSelectorInterfaceGenerator(),
                 Usings = new [] { "Sundew.Quantities.UnitSelection" },
             },
             new CodeGeneratorSetup
             {
                 Generator = new QuantityGenerator(),
                 TargetNamespace = Strings.Empty,
                 Usings = new []
                 {
                     "System",
                     "System.Globalization",
                     "Sundew.Quantities.Core",
                     "Sundew.Quantities.Representations.Expressions",
                     "Sundew.Quantities.UnitSelectors"
                 },
             },
         }
     }));
 }