private static ZenSettings ReadZenSettings(JsonReader reader) { ZenSettings settings = new ZenSettings(); Type objType = settings.GetType(); reader.Read(); if (reader.Token != JsonToken.ObjectStart) { return(null); } string currentProp = null; while (reader.Read()) { if (reader.Token == JsonToken.ObjectEnd) { break; } if (reader.Token == JsonToken.PropertyName) { currentProp = reader.Value.ToString(); } else if (reader.Token == JsonToken.ObjectStart) { if (currentProp == "variables") { settings.variables = ReadHashtable(reader); } else { settings.langs.Add(currentProp, ReadZenLang(reader)); } } } foreach (ZenLang lang in settings.langs.Values) { if (lang.extends != null && settings.langs.ContainsKey(lang.extends)) { ExtendLang(lang, settings.langs[lang.extends]); } } if (!settings.langs.ContainsKey("xml")) { ZenLang xlang = new ZenLang(); xlang.abbreviations = new Hashtable(); xlang.element_types = new ZenElementTypes(null); xlang.filters = "xml, xsl"; xlang.snippets = new Hashtable(); settings.langs.Add("xml", xlang); } settings.variables["child"] = ""; return(settings); }
private static void LoadResource(string file) { string path = Path.Combine(PathHelper.DataDir, "XMLCompletion"); string filePath = Path.Combine(path, file); try { if (!File.Exists(filePath) && !WriteResource(file, filePath)) { return; } settings = ZenSettings.Read(filePath); } catch (Exception ex) { ErrorManager.ShowError(ex); } }
private static ZenSettings ReadZenSettings(JsonReader reader) { ZenSettings settings = new ZenSettings(); Type objType = settings.GetType(); reader.Read(); if (reader.Token != JsonToken.ObjectStart) return null; string currentProp = null; while (reader.Read()) { if (reader.Token == JsonToken.ObjectEnd) break; if (reader.Token == JsonToken.PropertyName) currentProp = reader.Value.ToString(); else if (reader.Token == JsonToken.ObjectStart) { if (currentProp == "variables") settings.variables = ReadHashtable(reader); else settings.langs.Add(currentProp, ReadZenLang(reader)); } } foreach (ZenLang lang in settings.langs.Values) { if (lang.extends != null && settings.langs.ContainsKey(lang.extends)) ExtendLang(lang, settings.langs[lang.extends]); } if (!settings.langs.ContainsKey("xml")) { ZenLang xlang = new ZenLang(); xlang.abbreviations = new Hashtable(); xlang.element_types = new ZenElementTypes(null); xlang.filters = "xml, xsl"; xlang.snippets = new Hashtable(); settings.langs.Add("xml", xlang); } settings.variables["child"] = ""; return settings; }
private static void LoadResource(string file) { string path = Path.Combine(PathHelper.DataDir, "XMLCompletion"); string filePath = Path.Combine(path, file); try { if (!File.Exists(filePath) && !WriteResource(file, filePath)) return; settings = ZenSettings.Read(filePath); } catch (Exception ex) { ErrorManager.ShowError(ex); } }