public static IR1Top RResourceUnit(this IR1Top r1Top, IGResourceUnit gResourceUnit, IW1Top w1Top) { r1Top.Ct?.ThrowIfCancellationRequested(); StringBuilder localStringBuilder = new StringBuilder(); try { localStringBuilder.FetchFileAsStringBuilder("CResourceUnitPreambleTemplate.xml"); } catch (Exception e) { Console.WriteLine(e); // ToDo: better exception handling throw; } // ToDo: Figure out how to insert the header into the XML File Fetched as a template if (gResourceUnit.GResourceItems.Any()) { foreach (var kvp in gResourceUnit.GResourceItems) { localStringBuilder.RResourceItemStringBuilder(kvp.Value, r1Top.Eol, r1Top.Ct); } } localStringBuilder.Append($"</root>{r1Top.Eol}"); r1Top.Sb.Append(localStringBuilder); w1Top.WResourceUnit(gResourceUnit, r1Top.Sb); r1Top.Sb.Clear(); return(r1Top); }
public static IW1Top WResourceUnit(this IW1Top w1Top, IGResourceUnit gResourceUnit, StringBuilder sB, CancellationToken?ct = default) { var pathToDir = Path.Combine(w1Top.BasePath, gResourceUnit.GRelativePath); var pathToFile = Path.Combine(w1Top.BasePath, gResourceUnit.GRelativePath, gResourceUnit.GName + gResourceUnit.GFileSuffix); var transformDictionary = gResourceUnit.GPatternReplacement.GDictionary; IW1Top iW1Top; try { iW1Top = w1Top.WFile(pathToDir, pathToFile, transformDictionary, sB, ct); } catch (Exception e) { Console.WriteLine(e); // ToDo: better exception handling throw; } sB.Clear(); return(iW1Top); }
public static StringBuilder RenderResourceInProjectUnitStringBuilder(this StringBuilder sb, IGResourceUnit gResourceUnit, StringBuilder indent, string indentDelta, string eol, CancellationToken?ct = default) { ct?.ThrowIfCancellationRequested(); sb.Append( $"{indent}<EmbeddedResource Update=\"{gResourceUnit.GRelativePath}/{gResourceUnit.GName}{gResourceUnit.GFileSuffix}\">{eol}"); sb.Append($"{indent}{indentDelta}<Generator>PublicResXFileCodeGenerator</Generator >{eol}"); sb.Append($"{indent}{indentDelta}<LastGenOutput>{gResourceUnit.GName}.Designer.cs</LastGenOutput>{eol}"); sb.Append($"{indent}</EmbeddedResource>{eol}"); sb.Append($"{indent}<Compile Update=\"{gResourceUnit.GRelativePath}/{gResourceUnit.GName}.Designer.cs\">{eol}"); sb.Append($"{indent}{indentDelta}<DesignTime>True</DesignTime>{eol}"); sb.Append($"{indent}{indentDelta}<AutoGen >True</AutoGen>{eol}"); sb.Append($"{indent}{indentDelta}<DependentUpon>{gResourceUnit.GName}{gResourceUnit.GFileSuffix}</DependentUpon>{eol}"); sb.Append($"{indent}</Compile>{eol}"); return(sb); }
public static IR1Top RResourceUnitInProjectUnit(this IR1Top r1Top, IGResourceUnit gResourceUnit) { r1Top.Ct?.ThrowIfCancellationRequested(); r1Top.Sb.RenderResourceInProjectUnitStringBuilder(gResourceUnit, r1Top.Indent, r1Top.IndentDelta, r1Top.Eol, r1Top.Ct); return(r1Top); }