コード例 #1
0
ファイル: Schema.cs プロジェクト: keepingcode/make
 public void SetValues(string key, IEnumerable <string> values)
 {
     AddProperty(key);
     file.ClearProperty(key);
     foreach (var value in values)
     {
         file.AddValue(key, value);
     }
 }
コード例 #2
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);
            }
        }