public NullableContentWriter(Type type, IContentWriterCollection contentWriterCollection) { callHasValue = ReportEmitHelpers.EmitReadPropertyFunc(type.GetProperty("HasValue"), type); callGetValue = ReportEmitHelpers.EmitReadPropertyFunc(type.GetProperty("Value"), type); var valueType = type.GetGenericArguments()[0]; contentWriter = contentWriterCollection.Get(valueType); }
private void ProcessOtherProps(Type type, ICollection <Func <object, object> > funcList, ICollection <IValueWriter> list, ICollection <XmlElementInfo> xmlElementInfoList, IContentWriterCollection collection) { foreach (var propertyInfo in GetOrderedProperties(type)) { if (!IsAttr(propertyInfo) && propertyInfo.GetIndexParameters().Length == 0) { var elementInfo = xmlAttributeInterpreter.GetPropertyNodeInfo(propertyInfo, type); xmlElementInfoList.Add(elementInfo); var propertyType = propertyInfo.PropertyType; var emitReadPropertyFunc = ReportEmitHelpers.EmitReadPropertyFunc(propertyInfo, type); funcList.Add(emitReadPropertyFunc); if (propertyType == typeof(byte[])) { list.Add(new ByteArrayValueWriter(elementInfo)); } else if (propertyType.IsArray) { if (propertyType.GetArrayRank() > 1) { throw new NotSupportedException($"array with rank {propertyType.GetArrayRank()}"); } list.Add(new ArrayValueWriter(elementInfo, collection.Get(propertyType.GetElementType()))); } else if (propertyType.IsList()) { list.Add(new ListValueWriter(elementInfo, collection.Get(propertyType.GetListType()))); } else if (propertyType.IsDictionary()) { var keyWriter = collection.Get(propertyType.GetDictionaryKeyType()); var valueWriter = collection.Get(propertyType.GetDictionaryValueType()); list.Add(new DictionaryValueWriter(elementInfo, keyWriter, valueWriter, xmlAttributeInterpreter)); } else { list.Add(new ItemValueWriter(elementInfo, collection.Get(propertyType))); } } } }
private void ProcessAttributes(Type type, ICollection <Func <object, object> > funcList, ICollection <IValueWriter> list, ICollection <XmlElementInfo> xmlElementInfoList, IContentWriterCollection collection) { foreach (var propertyInfo in GetOrderedProperties(type)) { if (IsAttr(propertyInfo)) { funcList.Add(ReportEmitHelpers.EmitReadPropertyFunc(propertyInfo, type)); var xmlElementInfo = xmlAttributeInterpreter.GetPropertyNodeInfo(propertyInfo, type); xmlElementInfoList.Add(xmlElementInfo); list.Add(new AttributeValueWriter(xmlElementInfo, collection.Get(propertyInfo.PropertyType))); } } }
public RootContentWriter(Type type, IContentWriterCollection contentWriterCollection, IXmlAttributeInterpreter xmlAttributeInterpreter) { contentWriter = contentWriterCollection.Get(type); rootElementInfo = xmlAttributeInterpreter.GetRootNodeInfo(type); }