Write() 공개 정적인 메소드

public static Write ( TextWriter w, JsonSchemaSource root, string rootName ) : void
w TextWriter
root JsonSchemaSource
rootName string
리턴 void
예제 #1
0
        public static void GenerateTo(JsonSchemaSource root, DirectoryInfo dir, bool clearFolder)
        {
            // clear or create folder
            if (dir.Exists)
            {
                if (dir.EnumerateFileSystemInfos().Any())
                {
                    if (!clearFolder)
                    {
                        Console.WriteLine($"{dir} is not empty.");
                        return;
                    }

                    // clear
                    ClearFolder(dir);
                }
            }
            else
            {
                Console.WriteLine($"create: {dir}");
                dir.Create();
            }

            foreach (var s in root.Traverse())
            {
                // title を掃除
                s.title = CleanupTitle(s.title);
            }

            {
                var dst = Path.Combine(dir.FullName, "Format.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    FormatWriter.Write(w, root, GetStem(root.FilePath.Name));
                    File.WriteAllText(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
            {
                var dst = Path.Combine(dir.FullName, "Deserializer.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    DeserializerWriter.Write(w, root, GetStem(root.FilePath.Name));
                    File.WriteAllText(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
            {
                var dst = Path.Combine(dir.FullName, "Serializer.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    SerializerWriter.Write(w, root, GetStem(root.FilePath.Name));
                    File.WriteAllText(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
        }
예제 #2
0
파일: Generator.cs 프로젝트: vrm-c/UniVRM
        public static void GenerateTo(JsonSchemaSource root, DirectoryInfo formatDir, DirectoryInfo serializerDir)
        {
            CleanDirectory(formatDir);
            CleanDirectory(serializerDir);

            foreach (var s in root.Traverse())
            {
                // title を掃除
                s.title = CleanupTitle(s.title);
            }

            {
                var dst = Path.Combine(formatDir.FullName, "Format.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    FormatWriter.Write(w, root, GetStem(root.FilePath.Name));
                    WriteAllTextForce(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
            {
                var dst = Path.Combine(serializerDir.FullName, "Deserializer.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    DeserializerWriter.Write(w, root, GetStem(root.FilePath.Name));
                    WriteAllTextForce(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
            {
                var dst = Path.Combine(serializerDir.FullName, "Serializer.g.cs");
                Console.WriteLine(dst);
                using (var w = new StringWriter())
                {
                    SerializerWriter.Write(w, root, GetStem(root.FilePath.Name));
                    WriteAllTextForce(dst, w.ToString().Replace("\r\n", "\n"));
                }
            }
        }