示例#1
0
        internal ReferenceElementFieldData(Dictionary <string, object> values)
        {
            this._fields = new List <Element>();

            foreach (var item in values)
            {
                if (item.Value is double)
                {
                    Element elmDouble = new ReferenceElementDouble(item.Key, (double)item.Value);
                    this._fields.Add(elmDouble);
                }
                else if (item.Value is int)
                {
                    Element elmInt = new ReferenceElementInt(item.Key, (int)item.Value);
                    this._fields.Add(elmInt);
                }
                else if (item.Value is DateTime)
                {
                    Element elmDateTime = new ReferenceElementDateTime(item.Key, (DateTime)item.Value);
                    this._fields.Add(elmDateTime);
                }
                else if (item.Value is string)
                {
                    Element elmString = new ReferenceElementString(item.Key, (string)item.Value);
                    this._fields.Add(elmString);
                }
                else if (item.Value is ReferenceElementArrayChainTickers)
                {
                    this._fields.Add((ReferenceElementArrayChainTickers)item.Value);
                }
            }
        }
        internal ReferenceElementErrorInfo()
        {
            string sourceGibberish = Types.RandomDataGenerator.RandomString(5).ToLower();

            this._source      = new ReferenceElementString("source", string.Format("{0}::{1}{2}", Types.RandomDataGenerator.RandomInt(99), sourceGibberish, Types.RandomDataGenerator.RandomInt(99)));
            this._code        = new ReferenceElementInt("code", Types.RandomDataGenerator.RandomInt(99));
            this._category    = new ReferenceElementString("category", "BAD_FLD");
            this._message     = new ReferenceElementString("message", "Field not valid");
            this._subCategory = new ReferenceElementString("subcategory", "INVALID_FIELD");
        }
        internal ReferenceElementSecurityError(string security)
        {
            int    code            = Types.RandomDataGenerator.RandomInt(99);
            string sourceGibberish = Types.RandomDataGenerator.RandomString(5).ToLower();

            this._source      = new ReferenceElementString("source", string.Format("{0}::{1}{2}", code, sourceGibberish, Types.RandomDataGenerator.RandomInt(99)));
            this._code        = new ReferenceElementInt("code", code);
            this._category    = new ReferenceElementString("category", "BAD_SEC");
            this._message     = new ReferenceElementString("message", string.Format("Unknown/Invalid security [nid:{0}]", code));
            this._subCategory = new ReferenceElementString("subcategory", "INVALID_SECURITY");
        }
        public override void SetElement(string name, object value)
        {
            switch (name)
            {
            case "fieldId":
                this._fieldId = new ReferenceElementString(name, value.ToString());
                break;

            case "value":
                this._value = new ReferenceElementObject(name, value);
                break;

            default:
                throw new ArgumentException();
            }
        }
        internal ReferenceElementSecurityData(string securityName, Dictionary <string, object> fieldData, int sequenceNumber)
        {
            this._isSecurityError = Types.Rules.IsSecurityError(securityName);

            { //find bad field names
                List <string> badFields = new List <string>();
                foreach (var item in fieldData)
                {
                    if (Types.Rules.IsBadField(item.Key))
                    {
                        badFields.Add(item.Key);
                    }
                }

                //remove bad field names from the dictionary
                foreach (var item in badFields)
                {
                    fieldData.Remove(item);
                }

                if (badFields.Count == 0)
                {
                    this._elmFieldExceptions = null;
                }
                else
                {
                    this._elmFieldExceptions = new ReferenceElementFieldExceptionsArray(badFields);
                }
            }

            this._elmSecurityName = new ReferenceElementString("security", securityName);
            if (this._isSecurityError)
            {
                this._elmSequenceNumber = new ReferenceElementInt("sequenceNumber", sequenceNumber);
                this._elmSecError       = new ReferenceElementSecurityError(securityName);
                this._elmFieldData      = new ReferenceElementFieldData(new Dictionary <string, object>());
            }
            else
            {
                this._elmSequenceNumber = new ReferenceElementInt("sequenceNumber", sequenceNumber);
                this._elmSecError       = null;
                this._elmFieldData      = new ReferenceElementFieldData(fieldData);
            }
        }
        internal ReferenceElementArrayChainTickersItem(string ticker, DateTime dtExp, ReferenceElementArrayChainTickers.OptionalityEnum optionality, int strike)
        {
            string optionTicker = string.Format("{0} US {1:MM/dd/yy} {2}{3}", ticker, dtExp, (char)optionality, strike);

            this._element = new ReferenceElementString("Ticker", optionTicker);
        }
 internal ReferenceRequestElementOverride()
 {
     this._fieldId = new ReferenceElementString("fieldId", "");
     this._value   = new ReferenceElementObject("value", "");
 }
 public ReferenceElementFieldExceptions(string badField)
 {
     this._fieldId   = new ReferenceElementString("fieldId", badField);
     this._errorInfo = new ReferenceElementErrorInfo();
 }