public object this[string fieldID]
        {
            get
            {
                if (!this.pitems.ContainsKey(fieldID))
                {
                    throw new Exception(string.Format("Invalid field id:{0}.", (object)fieldID));
                }
                DataCollection.DataItem pitem = this.pitems[fieldID];
                if (pitem.Value == null || pitem.Value == DBNull.Value)
                {
                    return((object)DBNull.Value);
                }
                switch (pitem.ValueType)
                {
                case Enums.ValueType.Numeric:
                    return((object)(Decimal)pitem.Value);

                case Enums.ValueType.String:
                    return(pitem.Value.GetType() == typeof(string[]) ? (object)string.Join(",", pitem.Value as string[]) : (object)(string)pitem.Value);

                case Enums.ValueType.DateTime:
                    return((object)(DateTime)pitem.Value);

                default:
                    return((object)(string)pitem.Value);
                }
            }
        }
        public string GetString(string fieldID, IMapping mapping)
        {
            if (string.IsNullOrWhiteSpace(fieldID))
            {
                throw new ArgumentNullException(nameof(fieldID));
            }
            DataCollection.DataItem dataItem = this.GetItem(fieldID, mapping);
            if (dataItem == null || dataItem.Value == null)
            {
                return(string.Empty);
            }
            switch (dataItem.ValueType)
            {
            case Enums.ValueType.Numeric:
                return(dataItem.Value.GetType() == typeof(string[]) ? string.Join(",", ((IEnumerable <string>)(dataItem.Value as string[])).Select <string, string>((Func <string, string>)(s => string.Format("{0}", (object)s))).ToArray <string>()) : string.Format("{0}", dataItem.Value));

            case Enums.ValueType.String:
                return(dataItem.Value.GetType() == typeof(string[]) ? string.Join(",", ((IEnumerable <string>)(dataItem.Value as string[])).Select <string, string>((Func <string, string>)(s => string.Format("\"{0}\"", (object)s))).ToArray <string>()) : string.Format("\"{0}\"", (object)(string)dataItem.Value));

            case Enums.ValueType.DateTime:
                return(dataItem.Value.GetType() == typeof(string[]) ? string.Join(",", ((IEnumerable <string>)(dataItem.Value as string[])).Select <string, string>((Func <string, string>)(s => string.Format("#{0}#", (object)DateTime.Parse(s)))).ToArray <string>()) : string.Format("#{0}#", (object)(DateTime)dataItem.Value));

            default:
                return(object.Equals(dataItem.Value, (object)DBNull.Value) ? string.Empty : string.Format("{0}", dataItem.Value));
            }
        }
        public virtual DataCollection.DataItem GetItem(string fieldID, IMapping mapping)
        {
            if (string.IsNullOrWhiteSpace(fieldID))
            {
                throw new ArgumentNullException(nameof(fieldID));
            }
            bool flag             = false;
            ItemFilterEventArgs e = (ItemFilterEventArgs)null;

            if (this.ProcessItemFunc != null)
            {
                e = new ItemFilterEventArgs()
                {
                    Mapping = mapping,
                    FieldID = fieldID
                };
                if (this.ProcessItemFunc((object)this, e))
                {
                    flag = true;
                }
            }
            if (!flag && this.ProcessItem != null)
            {
                e = new ItemFilterEventArgs()
                {
                    Mapping = mapping,
                    FieldID = fieldID
                };
                if (this.ProcessItem((object)this, e))
                {
                    flag = true;
                }
            }
            if (flag)
            {
                DataCollection.DataItem dataItem = new DataCollection.DataItem()
                {
                    FieldID = fieldID,
                    Value   = e.Result
                };
                dataItem.ValueType = e.ValueType != Enums.ValueType.Unknown ? e.ValueType : DataCollection.GetValueType(e.Result);
                return(dataItem);
            }
            if (!this.pitems.ContainsKey(fieldID))
            {
                fieldID = this.ProcessFieldID(fieldID, mapping);
                if (!this.pitems.ContainsKey(fieldID))
                {
                    throw new Exception(string.Format("Invalid field id: {0}.", (object)fieldID));
                }
            }
            return(this.pitems[fieldID]);
        }
 public void WriteXml(XmlWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException(nameof(writer));
     }
     writer.WriteStartElement("Item");
     foreach (string key in (IEnumerable <string>) this.pitems.Keys)
     {
         DataCollection.DataItem pitem = this.pitems[key];
         writer.WriteElementString("FieldID", pitem.FieldID);
         writer.WriteElementString("Value", string.Format("{0}", pitem.Value));
         writer.WriteElementString("ValueType", pitem.ValueType.ToString());
     }
     writer.WriteEndElement();
 }
        protected virtual string GetDirectlyValue(IMapping mapping)
        {
            if (mapping == null)
            {
                throw new ArgumentNullException(nameof(mapping));
            }
            string fieldID = this.GetPreProcessedTranslation(mapping.Translation, mapping);

            if (fieldID.StartsWith("[") && fieldID.EndsWith("]"))
            {
                fieldID = fieldID.Substring(1, fieldID.Length - 2);
            }
            DataCollection.DataItem dataItem = this.GetItem(fieldID, mapping);
            if (dataItem == null || dataItem.Value == null)
            {
                return(string.Empty);
            }
            return((fieldID.ToUpper() == "LOAN.LASTMODIFIED" || fieldID.ToUpper() == "LOANLASTMODIFIED") && GlobalConfiguration.UseMilliSecondsForLastModified ? string.Format("{0}", (object)((DateTime)dataItem.Value).ToString("MM/dd/yyyy hh:mm:ss.fff tt")) : string.Format("{0}", dataItem.Value));
        }
        public virtual void Fill(IList <string> fieldIDs)
        {
            if (fieldIDs == null)
            {
                throw new ArgumentNullException(nameof(fieldIDs));
            }
            if (!this.CheckFieldIDs(fieldIDs))
            {
                throw new ArgumentException("Some field identities are invalid.");
            }
            if (this.pitems.Count == 0)
            {
                this.InitDefinition();
            }
            IList <string> stringList = (IList <string>) new List <string>(fieldIDs.Count);

            foreach (string fieldId in (IEnumerable <string>)fieldIDs)
            {
                if (!this.pitems.ContainsKey(fieldId) && !stringList.Contains(fieldId))
                {
                    if (!this.IsSystemField(fieldId))
                    {
                        stringList.Add(fieldId);
                    }
                }
            }
            foreach (string index in (IEnumerable <string>)stringList)
            {
                DataCollection.DataItem dataItem = this.CreateDataItem(index);
                if (dataItem != null)
                {
                    if (this.pitems.ContainsKey(index))
                    {
                        this.pitems[index] = dataItem;
                    }
                    else
                    {
                        this.pitems.Add(index, dataItem);
                    }
                }
            }
            GC.Collect();
        }
 public void SetItem(string fieldID, object fieldValue, Enums.ValueType valueType)
 {
     if (string.IsNullOrWhiteSpace(fieldID))
     {
         throw new ArgumentNullException(nameof(fieldID));
     }
     //if (fieldID.StartsWith("$") && !this.Silent)
     //    GlobalTracer.TraceVerboseFormat("start to set system field, {0}:{1}", (object)fieldID, fieldValue);
     if (this.pitems.ContainsKey(fieldID))
     {
         DataCollection.DataItem pitem = this.pitems[fieldID];
         pitem.Value     = fieldValue;
         pitem.ValueType = valueType;
     }
     else
     {
         DataCollection.DataItem dataItem = DataCollection.CreateItem(fieldID, fieldValue, valueType);
         this.pitems.Add(fieldID, dataItem);
     }
 }