예제 #1
0
        public Literature QueryLiterature()
        {
            string _path = string.Format(path, literature.GetParent(), literature.GetTitle());

            if (!File.Exists(_path))
            {
                return(null);
            }
            string json = File.ReadAllText(_path);

            return(serialize.DeSerialize(json));
        }
예제 #2
0
        public string Get(string id)
        {
            string  retStr = "1 RUB-";
            var     ser    = new Serialize();
            ValCurs quiz   = ser.DeSerialize <ValCurs>(SendRequest("http://www.cbr.ru/scripts/XML_daily.asp"));

            if (quiz.Valute.Any(x => x.CharCode == id.ToUpper()))
            {
                var item = Convert.ToDouble(quiz.Valute.FirstOrDefault(x => x.CharCode == id.ToUpper()).Value);
                var rate = Math.Round(1 / item, 4);
                retStr += rate.ToString() + " " +
                          id;
                return(retStr);
            }
            else
            {
                return("Валюта " + id.ToUpper() + " с таким кодом не найден в");
            }
        }