public async Task GenerateAndSaveIfChangedAsync_Pulls_Version_FromHeader() { //Arrange var options = new ClassGeneratorOptions { ClassName = "OurTest", Location = _location }; var generator = new StaticContentClassGenerator(options); var source = new MockContentSource(); source.SetData("en-US", new Dictionary <string, string> { { "A", "ValA" } }); await generator.GenerateAndSaveIfChangedAsync(new ContentVersion { Version = "1.0", ReleaseDate = new DateTime(2020, 1, 1) }, source); //Act var generator2 = new StaticContentClassGenerator(options); var version = await generator2.GetExistingVersionAsync(); //Assert Assert.Equal("1.0", version.Version); Assert.Equal(new DateTime(2020, 1, 1), version.ReleaseDate); }
public static string GenerateJs(JSBuilderModel model, ClassGeneratorOptions options) { var sbOut = new StringBuilder(); foreach (var cModel in model.FileClasses) { var sb = new StringBuilder(); if (options.IncludeHeaders) { BuildClassHeaders(sb); } BuildClassConstructor(cModel.ClassName, sb); foreach (var fileProperty in cModel.FileProperties) { if (fileProperty.IsArray) { BuildArrayProperty(sb, fileProperty, cModel.ClassName); } else { BuildPrimitiveProperty(sb, fileProperty); } } if (options.IncludeIsLoadingVar) { BuildLoadingVar(sb, options.ConversionType); } sb.AppendLine(" }"); // first close constructor parenthesis if (options.IncludeUnmapFunctions) { BuildUnmapFunction(sb, cModel.FileProperties, options.ConversionType); } BuildClassClosure(cModel.ClassName, sb); sbOut.AppendLine(sb.ToString()); sbOut.AppendLine(); } return(sbOut.ToString()); }
public async Task GeneratedFile_OnlyUpdates_For_New_Version() { //Arrange var options = new ClassGeneratorOptions { ClassName = "OurTest", Location = _location }; var generator = new StaticContentClassGenerator(options); var source = new MockContentSource(); source.SetData("en-US", new Dictionary <string, string> { { "A", "ValA" } }); await Task.Delay(100); //Act await generator.GenerateAndSaveIfChangedAsync(new ContentVersion { Version = "1.0", ReleaseDate = new DateTime(2020, 1, 1) }, source); var date1 = File.GetLastWriteTime(generator.GetFullFileName()); await Task.Delay(100); //same version await generator.GenerateAndSaveIfChangedAsync(new ContentVersion { Version = "1.0", ReleaseDate = new DateTime(2020, 1, 1) }, source); var date2 = File.GetLastWriteTime(generator.GetFullFileName()); await Task.Delay(100); //new version await generator.GenerateAndSaveIfChangedAsync(new ContentVersion { Version = "2.0", ReleaseDate = new DateTime(2020, 1, 1) }, source); var date3 = File.GetLastWriteTime(generator.GetFullFileName()); //Assert Assert.Equal(date1, date2); Assert.NotEqual(date1, date3); }
public static void CreateDataSetClasses (DataSet ds, CodeNamespace cns, ICodeGenerator gen, ClassGeneratorOptions options) { new Generator (ds, cns, gen, options).Run (); }
public Generator (DataSet ds, CodeCompileUnit cunit, CodeNamespace cns, CodeDomProvider codeProvider, ClassGeneratorOptions options) { this.ds = ds; this.cns = cns; this.opts = options; this.cunit = cunit; if (opts == null) opts = new ClassCodeDomProviderOptions (codeProvider); }
public Generator (DataSet ds, CodeNamespace cns, ICodeGenerator codeGen, ClassGeneratorOptions options) { this.ds = ds; this.cns = cns; this.opts = options; this.cunit = null; if (opts == null) opts = new ClassICodeGeneratorOptions (codeGen); }
public static void CreateDataSetClasses (DataSet ds, CodeCompileUnit cunit, CodeNamespace cns, CodeDomProvider codeProvider, ClassGeneratorOptions options) { new Generator (ds, cunit, cns, codeProvider, options).Run (); }
public Generator (DataSet ds, CodeNamespace cns, ICodeGenerator gen, ClassGeneratorOptions options) { this.ds = ds; this.cns = cns; this.gen = gen; this.opts = options; if (opts == null) opts = DefaultOptions; }