Пример #1
0
        public string Aktar(TcmbAktarFormat format, TcmbKurSort sort)
        {
            LoadData();
            if (Currency.Count() > 0)
            {
                UseSort(sort);

                var str = "";
                switch (format)
                {
                case TcmbAktarFormat.CSV:
                    str = CsvConverter.ToCsv <TcmbKurBilgi>(",", Currency);
                    break;

                case TcmbAktarFormat.JSON:
                    str = JsonConvert.SerializeObject(Currency);
                    break;

                case TcmbAktarFormat.XML:
                    var xmlserializer = new XmlSerializer(typeof(List <TcmbKurBilgi>));
                    var stringWriter  = new StringWriter();
                    using (var writer = XmlWriter.Create(stringWriter))
                    {
                        xmlserializer.Serialize(writer, Currency);
                        str = stringWriter.ToString();
                    }
                    break;

                default:
                    throw new Exception(ResultDescription.INVALID_FORMAT);
                }
                return(str);
            }
            else
            {
                throw new Exception(ResultDescription.INVALID_DATA);
            }
        }
Пример #2
0
 public string Aktar(TcmbAktarFormat format)
 {
     return(Aktar(format, TcmbKurSort.ASC));
 }