예제 #1
0
        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)));
                }
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
 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));
     }
 }
예제 #4
0
        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();
            }
        }
예제 #5
0
        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)));
        }
예제 #6
0
        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));
        }
예제 #7
0
 protected override string ResolvePropertyName(string propertyName)
 {
     return(_transform == null?base.ResolvePropertyName(propertyName) : _transform.Transform(propertyName));
 }
예제 #8
0
        public void Write(string message)
        {
            string formattedMessage = _textTransform.Transform(message);

            Console.WriteLine(formattedMessage);
        }