public HtmlGenerator(IH5DotJson_AssemblySettings config, TranslatorOutput outputs, string title, string buildConfig) { _assemblyConfig = config; _translatorOutputs = outputs; _title = title; _buildConfig = buildConfig; }
protected virtual MemberResolver Preconvert(MemberResolver resolver, IH5DotJson_AssemblySettings config, CancellationToken cancellationToken) { bool needRecompile = false; foreach (var sourceFile in ParsedSourceFiles) { cancellationToken.ThrowIfCancellationRequested(); Logger.ZLogTrace("Preconvert {0}", sourceFile.ParsedFile.FileName); var syntaxTree = sourceFile.SyntaxTree; var tempEmitter = new TempEmitter { AssemblyInfo = config }; var detecter = new PreconverterDetecter(resolver, tempEmitter); syntaxTree.AcceptVisitor(detecter); if (detecter.Found) { var fixer = new PreconverterFixer(resolver, tempEmitter); var astNode = syntaxTree.AcceptVisitor(fixer); syntaxTree = astNode != null ? (SyntaxTree)astNode : syntaxTree; sourceFile.SyntaxTree = syntaxTree; needRecompile = true; } } if (needRecompile) { return new MemberResolver(ParsedSourceFiles, resolver.Assemblies, AssemblyDefinition); } return resolver; }
public void ConvertConfigPaths(IH5DotJson_AssemblySettings assemblyInfo) { assemblyInfo.AfterBuild = helper.ConvertPath(assemblyInfo.AfterBuild); assemblyInfo.BeforeBuild = helper.ConvertPath(assemblyInfo.BeforeBuild); assemblyInfo.Output = helper.ConvertPath(assemblyInfo.Output); assemblyInfo.PluginsPath = helper.ConvertPath(assemblyInfo.PluginsPath); assemblyInfo.LocalesOutput = helper.ConvertPath(assemblyInfo.LocalesOutput); if (assemblyInfo.Html != null) { assemblyInfo.Html.Name = helper.ConvertPath(assemblyInfo.Html.Name); } if (assemblyInfo.Resources != null) { foreach (var resourceConfigItem in assemblyInfo.Resources.Items) { var files = resourceConfigItem.Files; if (files != null) { for (int i = 0; i < files.Length; i++) { var resourceItem = files[i]; files[i] = helper.ConvertPath(resourceItem); } } resourceConfigItem.Output = helper.ConvertPath(resourceConfigItem.Output); } } }
public Inspector(IH5DotJson_AssemblySettings config = null) { Types = new List <ITypeInfo>(); IgnoredTypes = new List <string>(); AssemblyInfo = config ?? new H5DotJson_AssemblySettings(); Emitter = new TempEmitter { AssemblyInfo = AssemblyInfo }; }
public void PreProcess(IH5DotJson_AssemblySettings translatorConfiguration = null) { AdjustH5Options(); _cancellationToken.ThrowIfCancellationRequested(); TranslatorConfiguration = translatorConfiguration ?? ReadConfiguration(); _cancellationToken.ThrowIfCancellationRequested(); Translator = SetTranslatorProperties(); Logger.LogInformation($"Ready to build {H5Options.ProjectLocation}"); }
private string CreateConfig(IH5DotJson_AssemblySettings h5Config, string folder) { var path = Path.Combine(folder, CONFIG_FILE_NAME); using (var textFile = File.CreateText(path)) { var jss = new JsonSerializerSettings() { Formatting = Formatting.Indented, ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }; var config = JsonConvert.SerializeObject(h5Config, jss); textFile.Write(config); } return(path); }
public void ApplyTokens(IH5DotJson_AssemblySettings config, ProjectProperties projectProperties) { Logger.LogTrace("ApplyTokens ..."); if (config == null) { throw new ArgumentNullException("config"); } if (projectProperties == null) { throw new ArgumentNullException("projectProperties"); } Logger.LogTrace("Properties:" + projectProperties.ToString()); var tokens = projectProperties.GetValues(); if (tokens == null || tokens.Count <= 0) { Logger.LogTrace("No tokens applied as no values to apply"); return; } config.FileName = helper.ApplyPathTokens(tokens, config.FileName); config.Output = helper.ApplyPathTokens(tokens, config.Output); config.BeforeBuild = helper.ApplyPathTokens(tokens, config.BeforeBuild); config.AfterBuild = helper.ApplyPathTokens(tokens, config.AfterBuild); config.PluginsPath = helper.ApplyPathTokens(tokens, config.PluginsPath); config.CleanOutputFolderBeforeBuild = helper.ApplyTokens(tokens, config.CleanOutputFolderBeforeBuild); config.CleanOutputFolderBeforeBuildPattern = helper.ApplyTokens(tokens, config.CleanOutputFolderBeforeBuildPattern); config.Locales = helper.ApplyTokens(tokens, config.Locales); config.LocalesOutput = helper.ApplyTokens(tokens, config.LocalesOutput); config.LocalesFileName = helper.ApplyPathTokens(tokens, config.LocalesFileName); if (config.Reflection != null) { config.Reflection.Filter = helper.ApplyTokens(tokens, config.Reflection.Filter); config.Reflection.Output = helper.ApplyTokens(tokens, config.Reflection.Output); } if (config.Resources != null) { foreach (var resourceItem in config.Resources.Items) { resourceItem.Header = helper.ApplyTokens(tokens, resourceItem.Header); resourceItem.Name = helper.ApplyTokens(tokens, resourceItem.Name); resourceItem.Remark = helper.ApplyTokens(tokens, resourceItem.Remark); var files = resourceItem.Files; if (files != null) { for (int i = 0; i < files.Length; i++) { files[i] = helper.ApplyPathTokens(tokens, files[i]); } } } } if (config.Html != null) { config.Html.Name = helper.ApplyTokens(tokens, config.Html.Name); } Logger.LogTrace("ApplyTokens done"); }
public static string ConfigToString(IH5DotJson_AssemblySettings config) { return(JsonConvert.SerializeObject(config)); }