Ejemplo n.º 1
0
        public SampleDynamicMBean()
        {
            var rowType = new CompositeType("Row", "Row", new[] {"ID", "Name"}, new[] {"Unique ID", "Name"},
                                         new[] {SimpleType.Integer, SimpleType.String});
             _tabularType = new TabularType("Table", "Table", rowType, new[] {"ID"});
             _tabularValue = new TabularDataSupport(_tabularType);

             _nestedCompositeValueType = new CompositeType("Nested composite value", "Nested composite value",
                                                       new[] {"NestedItem1", "NestedItem2"},
                                                       new[] {"Nested item 1", "Nested item 2"},
                                                       new[] {SimpleType.String, SimpleType.Double});
             _compositeValueType = new CompositeType("Composite value", "Composite value",
                                                 new[] {"Item1", "Item2", "Item3"},
                                                 new[] {"Item 1", "Item 2", "Item 3"},
                                                 new[]
                                                    {SimpleType.Integer, SimpleType.Boolean, _nestedCompositeValueType});

             var innerRowType = new CompositeType("Row", "Row", new[] {"ID", "Name", "CompositeValue"},
                                              new[] {"Unique ID", "Name", "Composite Value"},
                                              new[] {SimpleType.Integer, SimpleType.String, _compositeValueType});
             _innerTabularType = new TabularType("Inner table", "Inner table", innerRowType, new[] {"ID"});
             var outerRowType = new CompositeType("Outer Row", "Outer Row", new[] {"ID", "Value"},
                                              new[] {"Unique ID", "Tabular value"},
                                              new[] {SimpleType.Integer, _innerTabularType});
             _outerTabularType = new TabularType("Outer table", "Outer table", outerRowType, new[] {"ID"});
             _nestedTabularValue = new TabularDataSupport(_outerTabularType);
        }
Ejemplo n.º 2
0
 public SampleDynamicMBean()
 {
     _rowType = new CompositeType("Row", "Row", new[] { "ID", "Name" }, new[] { "Unique ID", "Name" },
                                  new[] { SimpleType.Integer, SimpleType.String });
     _tabularType = new TabularType("Table", "Table", _rowType, new[] { "ID" });
     _tabularValue = new TabularDataSupport(_tabularType);
     _arrayType = new ArrayType(1, SimpleType.Decimal);
 }
Ejemplo n.º 3
0
 public CompositeDataType_Type(CompositeType value)
     : base(value)
 {
     List<CompositeDataField> fields = new List<CompositeDataField>();
      foreach (string fieldName in value.KeySet)
      {
     fields.Add(new CompositeDataField(fieldName, value.GetDescription(fieldName), Serialize(value.GetOpenType(fieldName))));
      }
      CompositeDataField = fields.ToArray();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a CompositeDataSupport instance with the specified <paramref name="compositeType"/>, 
 /// whose item values are specified by <paramref name="itemValues"/>, in the same order as in 
 /// <paramref name="itemNames"/>. As a <see cref="compositeType"/> does not specify any order on its 
 /// items, the <see cref="itemNames"/> parameter is used to specify the order in which the values are 
 /// given in <paramref name="itemValues"/>. 
 /// </summary>
 /// <param name="compositeType">The composite type  of this composite data instance; must not be null.</param>
 /// <param name="itemNames">Must list, in any order, all the item names defined in 
 /// <paramref name="compositeType"/>; the order in which the names are listed, is used to match values in 
 /// <paramref name="itemValues"/>; must not be null or empty.</param>
 /// <param name="itemValues">The values of the items, listed in the same order as their respective names 
 /// in <paramref name="itemNames"/>; each item value can be null, but if it is non-null it must be a 
 /// valid value for the open type defined in <paramref name="compositeType"/> for the corresponding item; 
 /// must be of the same size as <paramref name="itemNames"/>; must not be null or empty.</param>
 public CompositeDataSupport(CompositeType compositeType, IEnumerable<string> itemNames, IEnumerable<object > itemValues)
 {
     if (compositeType == null)
      {
     throw new ArgumentNullException("compositeType");
      }
      if (itemNames == null)
      {
     throw new ArgumentNullException("itemNames");
      }
      if (itemValues == null)
      {
     throw new ArgumentNullException("itemValues");
      }
      IEnumerator<object> values = itemValues.GetEnumerator();
      foreach (string itemName in itemNames)
      {
     if (!values.MoveNext())
     {
        throw new OpenDataException("Names and value collections must have equal size.");
     }
     OpenType itemType = compositeType.GetOpenType(itemName);
     if (itemType == null)
     {
        throw new OpenDataException("Composite type doesn't have item with name "+itemName);
     }
     if (values.Current != null && !itemType.IsValue(values.Current))
     {
        throw new OpenDataException("Value is not valid for its item's open type.");
     }
     _items[itemName] = values.Current;
      }
      if (_items.Count != compositeType.KeySet.Count)
      {
     throw new OpenDataException(string.Format(CultureInfo.CurrentCulture,
                                               "Composite type has different item count ({0}) than count of items provided ({1}).",
                                               _items.Count, compositeType.KeySet.Count));
      }
      _compositeType = compositeType;
 }
Ejemplo n.º 5
0
 private static ICompositeData ExtractCompositeValue(CompositeType openType, CompositeData compositeData)
 {
     return new CompositeDataSupport(openType,
         compositeData.Properties.Select(x => x.Name),
         compositeData.Properties.Select(x => ExtractSimpleValue(openType.GetOpenType(x.Name), x.Value)));
 }
Ejemplo n.º 6
0
 private static CompositeData FormatCompositeValue(CompositeType compositeType, ICompositeData compositeData)
 {
     return new CompositeData(compositeType.KeySet.Select(x => new CompositeDataProperty(x, FormatSimpleValue(compositeType.GetOpenType(x), compositeData[x]))));
 }
Ejemplo n.º 7
0
 public CompositeDataBuilder(CompositeType type)
 {
     _type = type;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructs a CompositeDataSupport instance with the specified <paramref name="compositeType"/>, 
 /// whose item names and corresponding values are given by the mappings in the map <paramref name="items"/>.       
 /// </summary>
 /// <param name="compositeType">The composite type  of this composite data instance; must not be null.</param>
 /// <param name="items">The mappings of all the item names to their values; items must contain all the item 
 /// names defined in <paramref name="compositeType"/>; must not be null or empty.</param>
 public CompositeDataSupport(CompositeType compositeType, IDictionary<string, object > items)
     : this(compositeType,items != null ? items.Keys : null, items != null ? items.Values : null)
 {
 }
Ejemplo n.º 9
0
        private static ICompositeData MakeRowValue(ICompositeData elementValue, int index, CompositeType rowType)
        {
            List<string> names = new List<string>();
             List<object> values = new List<object>();

             names.Add(CollectionIndexColumnName);
             values.Add(index);

             foreach (string itemName in elementValue.CompositeType.KeySet)
             {
            names.Add(itemName);
            values.Add(elementValue[itemName]);
             }

             return new CompositeDataSupport(rowType, names, values);
        }
Ejemplo n.º 10
0
        private static CompositeType MakeRowType(CompositeType elementType)
        {
            List<string> names = new List<string>();
             List<string> descriptions = new List<string>();
             List<OpenType> types = new List<OpenType>();

             names.Add(CollectionIndexColumnName);
             descriptions.Add("Index of a collection");
             types.Add(SimpleType.Integer);

             foreach (string itemName in elementType.KeySet)
             {
            names.Add(itemName);
            descriptions.Add(elementType.GetDescription(itemName));
            types.Add(elementType.GetOpenType(itemName));
             }
             return new CompositeType(elementType.TypeName, elementType.Description, names, descriptions, types);
        }
Ejemplo n.º 11
0
        private static CompositeType MakeElementType(CompositeType rowType)
        {
            List<string> names = new List<string>();
             List<string> descriptions = new List<string>();
             List<OpenType> types = new List<OpenType>();

             foreach (string itemName in rowType.KeySet)
             {
            if (itemName != CollectionIndexColumnName)
            {
               names.Add(itemName);
               descriptions.Add(rowType.GetDescription(itemName));
               types.Add(rowType.GetOpenType(itemName));
            }
             }
             return new CompositeType(rowType.TypeName, rowType.Description, names, descriptions, types);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructs a CompositeDataSupport instance with the specified <paramref name="compositeType"/>,
 /// whose item names and corresponding values are given by the mappings in the map <paramref name="items"/>.
 /// </summary>
 /// <param name="compositeType">The composite type  of this composite data instance; must not be null.</param>
 /// <param name="items">The mappings of all the item names to their values; items must contain all the item
 /// names defined in <paramref name="compositeType"/>; must not be null or empty.</param>
 public CompositeDataSupport(CompositeType compositeType, IDictionary <string, object> items)
     : this(compositeType, items != null ? items.Keys : null, items != null ? items.Values : null)
 {
 }
Ejemplo n.º 13
0
 public override int GetHashCode()
 {
     return(_items.Aggregate(CompositeType.GetHashCode(),
                             (acc, x) => acc ^ GetValuePairHashCode(x)));
 }