| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- using GalaSoft.MvvmLight;
- using System;
- using GalaSoft.MvvmLight.Messaging;
- using Muchinfo.MTPClient.Data.Enums;
- namespace Muchinfo.MTPClient.Data.Model
- {
- /// <summary>
- /// GoodsBase类
- /// </summary>
- public abstract class GoodsBase : ObservableObject, IEquatable<GoodsBase>
- {
- #region Fields
- /// <summary>
- /// 交易所代码
- /// </summary>
- private string _exchHqCode;
- /// <summary>
- /// 商品代码
- /// </summary>
- private string _goodsCode;
- /// <summary>
- /// 商品Id
- /// </summary>
- private uint _goodsId;
- /// <summary>
- /// 序号
- /// </summary>
- private int _showIndex;
- #endregion Fields
- #region Constructors
- /// <summary>
- /// 构造一个基础商品
- /// </summary>
- /// <param name="exchangeCode">交易所代码</param>
- /// <param name="goodsCode">商品代码</param>
- /// <param name="goodsHqCode">商品代码</param>
- /// <exception cref="System.ArgumentNullException"></exception>
- protected GoodsBase(string exchangeCode, string goodsCode,string goodsHqCode)
- {
- //if (string.IsNullOrEmpty(exchangeCode))
- //{
- // throw new ArgumentNullException("exchangeCode");
- //}
- if (string.IsNullOrEmpty(goodsCode))
- {
- throw new ArgumentNullException("goodsCode");
- }
- //if (string.IsNullOrEmpty(goodsHqCode))
- //{
- // throw new ArgumentNullException("goodsHqCode");
- //}
- _exchHqCode = "250";//exchangeCode;
- _goodsCode = goodsCode;
- GoodsHqCode = goodsHqCode;
- }
- #endregion Constructors
- #region Properties
- #region Public Properties
- /// <summary>
- /// 获取基础商品的交易所代码
- /// </summary>
- public string ExchHqCode
- {
- get
- {
- return _exchHqCode;
- }
- set
- {
- Set(() => ExchHqCode, ref _exchHqCode, value);
- }
- }
- /// <summary>
- /// 获取基础商品的商品代码
- /// </summary>
- public string GoodsCode
- {
- get
- {
- return _goodsCode;
- }
- set
- {
- Set(() => GoodsCode, ref _goodsCode, value);
- }
- }
- /// <summary>
- /// 获取基础商品的商品Id
- /// </summary>
- public uint GoodsId
- {
- get
- {
- return _goodsId;
- }
- set
- {
- Set(() => GoodsId, ref _goodsId, value);
- }
- }
- private string _GoodsClassCode;
- /// <summary>
- /// 获取基础商品的商品品种代码
- /// </summary>
- public string GoodsClassCode
- {
- get
- {
- return _GoodsClassCode;
- }
- set
- {
- Set(() => GoodsClassCode, ref _GoodsClassCode, value);
- }
- }
- private string _GoodsClassName;
- /// <summary>
- /// 获取基础商品的商品品种名称
- /// </summary>
- public string GoodsClassName
- {
- get
- {
- return _GoodsClassName;
- }
- set
- {
- Set(() => GoodsClassName, ref _GoodsClassName, value);
- }
- }
-
- /// <summary>
- /// 获取和设置标签(获取行情时用)
- /// </summary>
- public string Symbol
- {
- get
- {
- return _exchHqCode.PadLeft(3, ' ') + GoodsHqCode.PadLeft(6, ' ');
- }
- }
- public string GoodsHqCode { get; set; }
- /// <summary>
- /// 序号
- /// </summary>
- public int ShowIndex
- {
- get
- {
- return _showIndex;
- }
- set
- {
- Set(() => ShowIndex, ref _showIndex, value);
- }
- }
- #endregion Public Properties
- #endregion Properties
- #region Methods
- #region Public Methods
- /// <summary>
- /// 比较与另一个对象是否指向相同一个事物
- /// </summary>
- /// <param name="obj">另一个对象</param>
- /// <returns>是否相同</returns>
- public override bool Equals(object obj)
- {
- if (obj != null)
- {
- var goods = obj as GoodsBase;
- if (goods != null)
- {
- return Equals(goods);
- }
- }
- return false;
- }
- /// <summary>
- /// 比较与另一个基础商品是否指向相同一个事物
- /// </summary>
- /// <param name="other">另一个基础商品</param>
- /// <returns>是否相同</returns>
- public bool Equals(GoodsBase other)
- {
- if (other == null)
- {
- return false;
- }
- return this.Symbol.Equals(other.Symbol);
- }
- /// <summary>
- /// 返回这个商品的HashCode
- /// </summary>
- /// <returns></returns>
- public override int GetHashCode()
- {
- return Symbol.GetHashCode();
- }
- /// <summary>
- /// 获取基础商品的字符串表达形式
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return "[" + Symbol + "]";
- }
- #endregion Public Methods
- #endregion Methods
- }
- }
|