/// <summary>Initializes a new instance of the <see cref="AutoTemplateBulb"/> class.</summary> /// <param name="scopeParameters">The scope.</param> /// <param name="autoTemplate">The smart template.</param> /// <param name="textRange">The document range.</param> public AutoTemplateBulb(Dictionary<string, string> scopeParameters, AutoTemplate autoTemplate, TextRange textRange) { this.ScopeParameters = scopeParameters; this.AutoTemplate = autoTemplate; this.TextRange = textRange; }
/// <summary>Loads this instance.</summary> private static void Load() { isLoaded = true; autoTemplates.Clear(); XDocument doc; try { lock (FileLock) { doc = XDocument.Load(GetAutoTemplatesFileName()); } } catch { return; } var root = doc.Root; if (root == null) { return; } foreach (var element in root.Elements()) { var template = new AutoTemplate { Key = element.GetAttributeValue("k"), Template = element.Value, Count = element.GetAttributeInt("c", 0), Percentage = element.GetAttributeInt("p", 0) }; var variables = element.GetAttributeValue("v").Split('|'); for (var index = 0; index < variables.Length - 1; index += 2) { template.TemplateVariables[variables[index]] = variables[index + 1]; } autoTemplates.Add(template); } }