Ejemplo n.º 1
0
        private int InitIniDictionary(IniCategory c)
        {
            List <bool> bools = default(List <bool>);
            XmlDocument xml   = new XmlDocument();

            if (File.Exists(path))
            {
                xml.Load(path);
            }
            dic = new Dictionary <string, string>();

            switch (c)
            {
            case IniCategory.Application:
                foreach (string s in _Ini_APP)
                {
                    dic[s] = ReadIniItemValue(xml, s);
                }
                b = _Ini_AB;
                break;

            case IniCategory.URLs:
                if (Properties.Settings.Default.qsource == QuandlAPI._PROVIDER)
                {
                    bools = new List <bool>();
                    for (int i = 0; i <= _Ini_URL.Length - 2; i++)
                    {
                        dic[_Ini_URL[i]] = ReadIniItemValue(xml, _Ini_URL[i]);
                        bools.Add(i < 2);
                    }
                    b = bools.ToArray();
                }
                else
                {
                    dic[_Ini_URL[2]] = ReadIniItemValue(xml, _Ini_URL[2]);
                    dic[_Ini_URL[3]] = ReadIniItemValue(xml, _Ini_URL[3]);
                    dic[_Ini_URL[4]] = ReadIniItemValue(xml, _Ini_URL[4]);
                    dic[_Ini_URL[_Ini_URL.Length - 1]] = ReadIniItemValue(xml, _Ini_URL[_Ini_URL.Length - 1]);
                    b = new bool[] { false, false, false, false };
                }
                break;

            case IniCategory.APIKeys:
                foreach (CommodityType k in Enum.GetValues(typeof(CommodityType)))
                {
                    if (k == CommodityType.None)
                    {
                        continue;
                    }
                    dic[((int)k).ToString()] = ReadIniItemValue(xml, ((int)k).ToString());
                }
                b = new bool[] { true, true, true, true };
                break;
            }

            return(dic.Count);
        }
Ejemplo n.º 2
0
        public static string APIIniPath(string provider, IniCategory ic)
        {
            string p;

            p = HomePath + Path.DirectorySeparatorChar + provider; if (!Directory.Exists(p))
            {
                Directory.CreateDirectory(p);
            }
            if (ic == IniCategory.APIKeys)
            {
                p += Path.DirectorySeparatorChar + Properties.Settings.Default.keys_ini;
            }
            else if (ic == IniCategory.URLs)
            {
                p += Path.DirectorySeparatorChar + Properties.Settings.Default.urls_ini;
            }


            return(p);
        }