Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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);
     }
 }