示例#1
0
        public SchemaFile Deserialize(SourceReader source)
        {
            using (source)
            {
                var file   = new SchemaFile();
                var reader = source.GetReader();

                string line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.TrimStart().StartsWith("#"))
                    {
                        var text = line.Trim();
                        text = text.Substring(1);
                        file.AddComment(text);
                    }
                    else if (line.Trim().Length == 0)
                    {
                        file.AddEmptyLine();
                    }
                    else if (line.StartsWith(" "))
                    {
                        var value = line.Trim();
                        if (value == "(null)")
                        {
                            value = null;
                        }
                        file.AddValue(value);
                    }
                    else
                    {
                        file.AddProperty(line.Trim());
                    }
                }

                return(file);
            }
        }
示例#2
0
 public Schema(SchemaFile file)
 {
     this.file = file;
 }
示例#3
0
        public static Schema Parse(SourceReader source)
        {
            var file = SchemaFile.Parse(source);

            return(new Schema(file));
        }
示例#4
0
 public Schema()
 {
     this.file = new SchemaFile();
 }