public static void CreateFromTemplate(this ITextTransform transform, LPath source, LPath destination) { // Console.WriteLine("{0} -> {1}", source, destination); if (source.IsFile) { destination.EnsureParentDirectoryExists(); if (IsBinaryFile(source)) { source.CopyFile(destination); } else { using (var w = destination.WriteText()) using (var r = source.ReadText()) { transform.Transform(r, w); } } } else { foreach (var i in source.Info.GetChildren()) { transform.CreateFromTemplate(i.FullName, destination.CatDir(transform.Transform(i.Name))); } } }
/// <summary> /// Appends the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="transformer">The transformer.</param> /// <returns>The SQL builder.</returns> public ISqlBuilder Append(string value, ITextTransform transformer) { Check.NotNull(nameof(transformer), transformer); this.builder.Append(transformer.Transform(value)); return(this); }
public static void Transform(this ITextTransform transform, TextReader input, TextWriter output) { for (; ;) { var line = input.ReadLine(); if (line == null) { break; } output.WriteLine(transform.Transform(line)); } }
public void ProcessRequest(IHttpContext context) { var fileStream = fileSystem.OpenRead(context.Request.FilePath); using (var streamReader = new StreamReader(fileStream)) { var fileText = streamReader.ReadToEnd(); var responseText = textTransform.Transform(fileText); var streamWriter = new StreamWriter(context.Response.OutputStream); streamWriter.Write(responseText); streamWriter.Flush(); } }
public static StringBuilder AppendTransform( this StringBuilder builder, string identifier, ITextTransform transformer) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (transformer is null) { throw new ArgumentNullException(nameof(transformer)); } return(builder.Append( transformer.Transform(identifier))); }
public static StringBuilder AppendQuote( this StringBuilder builder, string value, ITextTransform transformer, char leftQuote = '"', char rightQuote = '"') { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (transformer is null) { throw new ArgumentNullException(nameof(transformer)); } return(builder.Append(leftQuote) .Append(transformer.Transform(value)) .Append(rightQuote)); }
protected override string ResolvePropertyName(string propertyName) { return(_transform == null?base.ResolvePropertyName(propertyName) : _transform.Transform(propertyName)); }
public void Write(string message) { string formattedMessage = _textTransform.Transform(message); Console.WriteLine(formattedMessage); }