示例#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)));
                }
            }
        }