private IList <Field> DeserialiseFields(IList <string> templatePath) { var fields = new Dictionary <long, Field>(); var fieldsPath = MakePath(templatePath, "Field"); foreach (var key in EnumerateKeys(fieldsPath)) { var fieldPath = MakePath(fieldsPath, SerialisationMetadata.FormatKey(key)); var editable = true; if (TryGetValue(fieldPath, "InitialRange", out long initialRange)) { editable = initialRange != -1; } TryGetValue(fieldPath, "Expression", out string expression); var order = GetValue <long>(fieldPath, "Order"); var field = new Field { Name = key, Editable = editable, Expression = expression, EditableInstance = initialRange }; fields.Add(order, field); } return(fields.OrderBy(f => f.Key).Select(f => f.Value).ToList()); }
private Template DeserialiseTemplate(Guid guid) { var templateKey = SerialisationMetadata.FormatKey(SerialisationMetadata.FormatGuid(guid)); var templatePath = MakePath(RootPath, templateKey); var template = new Template { Guid = guid }; var index = GetIndexedValues <bool>(templatePath, "Applicability").First().Key; Enum.TryParse(index, out template.Type); if (template.Type != TemplateType.File) { template.Shortcut = GetValue <string>(templatePath, "Shortcut"); } if (!TryGetValue(templatePath, "Description", out string description)) { Console.WriteLine("Warning: Template {0} does not have a description.", template.Shortcut); } template.Description = description; template.Text = GetValue <string>(templatePath, "Text"); template.Image = TryGetValue(templatePath, "Image", (string)null); template.Reformat = TryGetValue(templatePath, "Reformat", true); template.ShortenQualifiedReferences = TryGetValue(templatePath, "ShortenQualifiedReferences", true); template.Scopes = DeserialiseScopes(templatePath); template.CustomProperties = DeserialiseCustomProperties(templatePath); template.Categories = DeserialiseCategories(templatePath); template.Fields = DeserialiseFields(templatePath); return(template); }
public SettingsStore AddIndexedSettings(string name, string index) { var newPath = Combine(path, name, SerialisationMetadata.FormatKey(index)); var settings = new SettingsStore(dictionary, newPath); settings.Add(SerialisationMetadata.KeyIndexDefined, true); return(settings); }
private IDictionary <string, T> GetIndexedValues <T>(IList <string> path, string name) { var dictionary = new Dictionary <string, T>(); var keys = trie.GetChildKeys(path.Concat(new[] { name })); foreach (var index in keys) { var value = trie.GetValue(MakePath(path, name, index, SerialisationMetadata.EntryIndexedValue)); var key = SerialisationMetadata.ParseKey(index); dictionary.Add(key, (T)value); } return(dictionary); }
private Scope DeserialiseScope(IEnumerable <string> templatePath, Guid guid) { var scopePath = MakePath(templatePath, "Scope", SerialisationMetadata.FormatKey(SerialisationMetadata.FormatGuid(guid))); var scope = new Scope { Guid = guid, Type = GetValue <string>(scopePath, "Type"), Parameters = DeserialiseScopeParameters(scopePath) }; return(scope); }
private IEnumerable <string> EnumerateKeys(IEnumerable <string> path) { return(from key in trie.GetChildKeys(path) select SerialisationMetadata.ParseKey(key)); }
private IEnumerable <Guid> GetScopeGuids(IEnumerable <string> templatePath) { return(from key in EnumerateKeys(MakePath(templatePath, "Scope")) select SerialisationMetadata.ParseGuid(key)); }
private IEnumerable <Guid> GetTemplateGuids() { return(from key in EnumerateKeys(RootPath) select SerialisationMetadata.ParseGuid(key)); }
public void AddIndexedValue(string name, string key, object value) { Add(Combine(name, SerialisationMetadata.FormatKey(key), SerialisationMetadata.EntryIndexedValue), value); }
public SettingsStore AddIndexedSettings(string name, Guid index) { return(AddIndexedSettings(name, SerialisationMetadata.FormatGuid(index))); }