public object Deserialize() { Type listType = typeof(List <>).MakeGenericType(Type.GetType(JmxTypeMapping.GetCLRTypeName(leafType))); object results = Activator.CreateInstance(listType); foreach (GenericValueType valueType in Value) { listType.GetMethod("Add").Invoke(results, new[] { valueType.Deserialize() }); } return(results); }
public object Deserialize() { Type dictType = typeof(Dictionary <,>).MakeGenericType( Type.GetType(JmxTypeMapping.GetCLRTypeName(keyType)), Type.GetType(JmxTypeMapping.GetCLRTypeName(valueType))); object results = Activator.CreateInstance(dictType); foreach (MapTypeEntry entry in Entry) { dictType.GetMethod("Add").Invoke(results, new[] { entry.Key.Deserialize(), entry.Value.Deserialize() }); } return(results); }
public TypedMultipleValueType(ICollection values) { Type elementType = values.GetType().GetInterface("ICollection`1").GetGenericArguments()[0]; leafType = JmxTypeMapping.GetJmxXmlType(elementType.AssemblyQualifiedName); List <GenericValueType> valueTypes = new List <GenericValueType>(); foreach (object value in values) { valueTypes.Add(new GenericValueType(value)); } Value = valueTypes.ToArray(); }
public TypedMapType(IDictionary value) { Type[] argumentTypes = value.GetType().GetInterface("IDictionary`2").GetGenericArguments(); keyType = JmxTypeMapping.GetJmxXmlType(argumentTypes[0].AssemblyQualifiedName); valueType = JmxTypeMapping.GetJmxXmlType(argumentTypes[1].AssemblyQualifiedName); List <MapTypeEntry> mapTypeEntries = new List <MapTypeEntry>(); foreach (DictionaryEntry entry in value) { mapTypeEntries.Add(new MapTypeEntry { Key = new GenericValueType(entry.Key), Value = new GenericValueType(entry.Value) }); } Entry = mapTypeEntries.ToArray(); }