示例#1
0
        private static ITabularData ExtractTabularValue(TabularType openType, CompositeData[] value)
        {
            var tabularValue = new TabularDataSupport(openType);

            tabularValue.PutAll(value.Select(x => ExtractCompositeValue(openType.RowType, x)));
            return(tabularValue);
        }
 public object Deserialize()
 {
     ITabularData result = new TabularDataSupport((TabularType) TabularDataType.Deserialize());
      if (Values != null)
      {
     result.PutAll(Values.Select(x => x.Deserialize()).Cast<ICompositeData>());
      }
      return result;
 }
示例#3
0
        public object Deserialize()
        {
            ITabularData result = new TabularDataSupport((TabularType)TabularDataType.Deserialize());

            if (Values != null)
            {
                result.PutAll(Values.Select(x => x.Deserialize()).Cast <ICompositeData>());
            }
            return(result);
        }
示例#4
0
        public void AddNestedRow(int outerId, int innerId, string name)
        {
            var nestedCompositeValue = new CompositeDataSupport(_nestedCompositeValueType,
                                                                new[] { "NestedItem1", "NestedItem2" },
                                                                new object[] { "1", 5.7 });
            var compositeValue = new CompositeDataSupport(_compositeValueType, new[] { "Item1", "Item2", "Item3" },
                                                          new object[] { 1, false, nestedCompositeValue });
            var innerRow = new CompositeDataSupport(_innerTabularType.RowType, new[] { "ID", "Name", "CompositeValue" },
                                                    new object[] { outerId, name, compositeValue });
            var innerTable = new TabularDataSupport(_innerTabularType);

            innerTable.Put(innerRow);
            var outerRow = new CompositeDataSupport(_outerTabularType.RowType, new[] { "ID", "Value" },
                                                    new object[] { innerId, innerTable });

            _nestedTabularValue.Put(outerRow);
        }
示例#5
0
        public object MapValue(Type plainNetType, OpenType mappedType, object value, MapValueDelegate mapNestedValueCallback)
        {
            if (value == null)
            {
                return(null);
            }
            Type elementType = GetElementType(plainNetType);

            if (mappedType.Kind == OpenTypeKind.ArrayType)
            {
                if (value.GetType().IsArray)
                {
                    return(value);
                }
                else
                {
                    ArrayList   result          = new ArrayList();
                    IEnumerable enumerableValue = (IEnumerable)value;
                    foreach (object o in enumerableValue)
                    {
                        result.Add(o);
                    }
                    return(result.ToArray(elementType));
                }
            }
            else
            {
                TabularType  tabularType     = (TabularType)mappedType;
                ITabularData result          = new TabularDataSupport(tabularType, 0);
                IEnumerable  enumerableValue = (IEnumerable)value;
                int          index           = 0;
                foreach (object o in enumerableValue)
                {
                    ICompositeData element = (ICompositeData)mapNestedValueCallback(elementType, MakeElementType(tabularType.RowType), o);
                    result.Put(MakeRowValue(element, index, tabularType.RowType));
                    index++;
                }
                return(result);
            }
        }
示例#6
0
 private static ITabularData ExtractTabularValue(TabularType openType, CompositeData[] value)
 {
     var tabularValue = new TabularDataSupport(openType);
     tabularValue.PutAll(value.Select(x => ExtractCompositeValue(openType.RowType, x)));
     return tabularValue;
 }
示例#7
0
 public void AddNestedRow(int outerId, int innerId, string name)
 {
     var nestedCompositeValue = new CompositeDataSupport(_nestedCompositeValueType,
                                                      new[] {"NestedItem1", "NestedItem2"},
                                                      new object[] {"1", 5.7});
      var compositeValue = new CompositeDataSupport(_compositeValueType, new[] {"Item1", "Item2", "Item3"},
                                                new object[] {1, false, nestedCompositeValue});
      var innerRow = new CompositeDataSupport(_innerTabularType.RowType, new[] {"ID", "Name", "CompositeValue"},
                                          new object[] {outerId, name, compositeValue});
      var innerTable = new TabularDataSupport(_innerTabularType);
      innerTable.Put(innerRow);
      var outerRow = new CompositeDataSupport(_outerTabularType.RowType, new[] {"ID", "Value"},
                                          new object[] {innerId, innerTable});
      _nestedTabularValue.Put(outerRow);
 }
 public ICompositeDataBuilder Table(string name, Action<ITabularData> nestedTabularBuilder)
 {
     if (name == null)
      {
     throw new ArgumentNullException("name");
      }
      if (nestedTabularBuilder == null)
      {
     throw new ArgumentNullException("nestedTabularBuilder");
      }
      TabularType nestedTabularType = _type.GetOpenType(name) as TabularType;
      if (nestedTabularType == null)
      {
     throw new InvalidOperationException(string.Format("Item {0} is not of TabularType", name));
      }
      TabularDataSupport nestedTable = new TabularDataSupport(nestedTabularType);
      nestedTabularBuilder(nestedTable);
      _items.Add(name, nestedTable);
      return this;
 }
 public object MapValue(Type plainNetType, OpenType mappedType, object value, MapValueDelegate mapNestedValueCallback)
 {
     if (value == null)
      {
     return null;
      }
      Type elementType = GetElementType(plainNetType);
      if (mappedType.Kind == OpenTypeKind.ArrayType)
      {
     if (value.GetType().IsArray)
     {
        return value;
     }
     else
     {
        ArrayList result = new ArrayList();
        IEnumerable enumerableValue = (IEnumerable)value;
        foreach (object o in enumerableValue)
        {
           result.Add(o);
        }
        return result.ToArray(elementType);
     }
      }
      else
      {
     TabularType tabularType = (TabularType) mappedType;
     ITabularData result = new TabularDataSupport(tabularType, 0);
     IEnumerable enumerableValue = (IEnumerable) value;
     int index = 0;
     foreach (object o in enumerableValue)
     {
        ICompositeData element = (ICompositeData) mapNestedValueCallback(elementType, MakeElementType(tabularType.RowType), o);
        result.Put(MakeRowValue(element, index, tabularType.RowType));
        index++;
     }
     return result;
      }
 }