Example #1
0
        static public RICustomData GetCollection(IEnumerable enumerator, ObjectScope scope)
        {
            RICustomDataFieldIdType             fType = RICustomDataFieldIdType.Integer;
            RICustomDataColumnJustificationType sIndexJustification = RICustomDataColumnJustificationType.Right;
            string sIndex = "Index";

            if (enumerator is IDictionary)
            {
                sIndex = "Key";
                fType  = RICustomDataFieldIdType.String;
                sIndexJustification = RICustomDataColumnJustificationType.Left;
            }

            List <RICustomDataColumn> columns = new List <RICustomDataColumn>();

            columns.Add(new RICustomDataColumn(sIndex, fType, null, null, sIndexJustification));
            columns.Add(new RICustomDataColumn("Value"));
            columns.Add(new RICustomDataColumn("Type"));

            RICustomData cData = new RICustomData(enumerator.GetType().FullName, columns, true, false);

            cData.AllowSort  = true;
            cData.HasDetails = scope != ObjectScope.None;

            using (var pool = FastFormatterPool.Pool.Container())
            {
                if (enumerator is IDictionary)
                {
                    IDictionary collection = (IDictionary)enumerator;
                    foreach (Object key in collection.Keys)
                    {
                        Object          value = collection[key];
                        RICustomDataRow row   = cData.AddRow(key != null ? key.ToString() : null, value != null ? value.ToString() : null, value != null ? value.GetType().FullName : null);
                        if (!cData.HasDetails || value == null)
                        {
                            continue;
                        }

                        row.SetExtraData(pool.Instance, ObjectBuilder.BuildObjectPropertyMap(value, scope));
                    }
                }
                else
                {
                    Int32 index = 0;
                    foreach (Object value in enumerator)
                    {
                        RICustomDataRow row = cData.AddRow(index++, value != null ? value.ToString() : null, value != null ? value.GetType().FullName : null);
                        if (!cData.HasDetails || value == null)
                        {
                            continue;
                        }

                        row.SetExtraData(pool.Instance, ObjectBuilder.BuildObjectPropertyMap(value, scope));
                    }
                }
            }

            return(cData);
        }
Example #2
0
 public virtual void ReadData(FastBinaryReader reader, Object additionalInfo)
 {
     FieldTypeId   = (RICustomDataFieldIdType)reader.ReadInt32();
     Justification = (RICustomDataColumnJustificationType)reader.ReadInt32();
     Caption       = reader.ReadSafeString();
     Format        = reader.ReadSafeString();
     NullText      = reader.ReadSafeString();
 }
Example #3
0
        public RICustomDataColumn(String caption, RICustomDataFieldIdType fieldTypeId, String format, String nullText, RICustomDataColumnJustificationType justification)
        {
            FieldTypeId   = fieldTypeId;
            Justification = justification;
            Caption       = caption;
            Format        = format ?? "{0}";
            NullText      = nullText ?? "(null)";

            if (fieldTypeId == RICustomDataFieldIdType.DateTime && String.Compare(Format, "{0}", false) == 0)
            {
                Format = String.Empty;
            }
        }