using Muchinfo.MTPClient.Data.Quote.Enum;
using System;
using System.Collections.Generic;
namespace Muchinfo.MTPClient.Data.Quote.Entities
{
///
/// Class QuoteTik. -- From Muchinfo.Quote.Messages.dll
///
public class QuoteTik
{
private Dictionary _fields;
private string _date;
private string _time;
public Dictionary Fields
{
get
{
return this._fields;
}
}
public string ExchangeCode
{
get;
set;
}
public string GoodsCode
{
get;
set;
}
public int Sort
{
get;
set;
}
public string Symbol
{
get
{
string text = this.ExchangeCode;
string text2 = this.GoodsCode;
if (text != null && string.IsNullOrEmpty(text) && text.Length > 3)
{
text = text.Substring(0, 3);
}
if (text2 != null && string.IsNullOrEmpty(text2) && text2.Length > 6)
{
text2 = text2.Substring(text2.Length - 6, 6);
}
string text3 = text.PadLeft(3, ' ') + text2.PadLeft(6, ' ');
return text3.ToUpperInvariant();
}
}
public DateTime AtTime
{
get;
set;
}
public byte DecimalPlace
{
get;
set;
}
public string Date
{
get
{
return this._date;
}
set
{
this._date = value;
this.SetAtTime();
}
}
public string Time
{
get
{
return this._time;
}
set
{
this._time = value;
this.SetAtTime();
}
}
public QuoteTik()
{
this._fields = new Dictionary();
this.DecimalPlace = 4;
}
private void SetAtTime()
{
if (!string.IsNullOrEmpty(this.Date) && this.Date.Length >= 8)
{
int year = int.Parse(this._date.Substring(0, 4));
int month = int.Parse(this._date.Substring(4, 2));
int day = int.Parse(this._date.Substring(6, 2));
this.AtTime = new DateTime(year, month, day, this.AtTime.Hour, this.AtTime.Minute, this.AtTime.Second);
}
if (string.IsNullOrEmpty(this.Time) || this.Time.Length < 6)
{
return;
}
int hour = int.Parse(this._time.Substring(0, 2));
int minute = int.Parse(this._time.Substring(2, 2));
int second = int.Parse(this._time.Substring(4, 2));
this.AtTime = new DateTime(this.AtTime.Year, this.AtTime.Month, this.AtTime.Day, hour, minute, second);
}
}
}