コード例 #1
0
        void WriteObject(ObjectJsonSchema schema, string rootName = default)
        {
            if (m_used.Contains(schema.Title))
            {
                return;
            }
            m_used.Add(schema.Title);

            var className = schema.Title;

            m_w.Write($@"
    public class {className}
    {{
");

            if (!string.IsNullOrEmpty(rootName))
            {
                var indent = "        ";
                m_w.WriteLine($"{indent}public const string ExtensionName = \"{rootName}\";");
                m_w.WriteLine($"{indent}public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName);");
                m_w.WriteLine();
            }

            var isFirst = true;

            foreach (var kv in schema.Properties)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    m_w.WriteLine();
                }
                if (!string.IsNullOrEmpty(kv.Value.Description))
                {
                    m_w.WriteLine($"{FieldIndent}// {kv.Value.Description}");
                }
                var(attr, propType) = PropType(kv.Value);
                if (!string.IsNullOrEmpty(attr))
                {
                    m_w.WriteLine($"{FieldIndent}{attr}");
                }
                m_w.WriteLine($"{FieldIndent}public {propType} {kv.Key.ToUpperCamel()};");
            }

            // close class
            m_w.WriteLine("    }");
        }
コード例 #2
0
 public ProtoNode(string path, ObjectJsonSchema schema)
 {
     Path   = path;
     Schema = schema;
 }