void Generate(IClassInfoGraphNode classInfoGraphNode, ITypeInfo memberInfo, ObjectSpace objectSpace, Action<IList<IMemberInfo>> action) { foreach (var infoGraphNode in GetGraph(objectSpace, memberInfo.Type, action)) { classInfoGraphNode.Children.Add(infoGraphNode); } }
void SetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement propertyElement) { var xpMemberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (xpMemberInfo != null) { var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name); if (xpMemberInfo.Converter != null) { memberValue = (xpMemberInfo.Converter.ConvertToStorageType(memberValue)); } if (memberValue is byte[]) { memberValue = Convert.ToBase64String((byte[])memberValue); } if (memberValue is DateTime) { memberValue = ((DateTime)memberValue).Ticks; } if (memberValue is string) { memberValue = IAFModule.SanitizeXmlString((string)memberValue); propertyElement.Add(new XCData(memberValue.ToString())); } else { propertyElement.Value = GetInvariantValue(memberValue); } } }
void createCollectionProperty(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root, XElement propertyElement) { XPMemberInfo memberInfo = selectedObject.ClassInfo.GetMember(classInfoGraphNode.Name); var theObjects = (XPBaseCollection)memberInfo.GetValue(selectedObject); foreach (XPBaseObject theObject in theObjects) { CreateRefElelement(classInfoGraphNode,theObject.GetType().Name, root, theObject, propertyElement); } }
object GetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode) { var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name); var xpMemberInfo = selectedObject.ClassInfo.GetMember(classInfoGraphNode.Name); if (xpMemberInfo.Converter!= null){ return xpMemberInfo.Converter.ConvertToStorageType(memberValue); } return memberValue; }
XElement GetPropertyElement(XElement serializedObjectElement, IClassInfoGraphNode classInfoGraphNode) { var propertyElement = new XElement("Property"); serializedObjectElement.Add(propertyElement); propertyElement.Add(new XAttribute("type", classInfoGraphNode.NodeType.ToString().MakeFirstCharLower())); propertyElement.Add(new XAttribute("name", classInfoGraphNode.Name)); propertyElement.Add(new XAttribute("isKey", classInfoGraphNode.Key)); return propertyElement; }
IClassInfoGraphNode CreateComplexNode(IMemberInfo memberInfo, IObjectSpace objectSpace) { NodeType nodeType = memberInfo.MemberTypeInfo.IsPersistent ? NodeType.Object : NodeType.Collection; IClassInfoGraphNode classInfoGraphNode = CreateClassInfoGraphNode(objectSpace, memberInfo, nodeType); classInfoGraphNode.SerializationStrategy = GetSerializationStrategy(memberInfo, SerializationStrategy.SerializeAsObject); Generate(objectSpace, ReflectionHelper.GetType(classInfoGraphNode.TypeName)); return(classInfoGraphNode); }
XElement GetPropertyElement(XElement serializedObjectElement, IClassInfoGraphNode classInfoGraphNode) { var propertyElement = new XElement("Property"); serializedObjectElement.Add(propertyElement); propertyElement.Add(new XAttribute("type", classInfoGraphNode.NodeType.ToString().MakeFirstCharLower())); propertyElement.Add(new XAttribute("name", classInfoGraphNode.Name)); propertyElement.Add(new XAttribute("isKey", classInfoGraphNode.Key)); return(propertyElement); }
void CreateObjectProperty(ITypeInfo typeInfo, object selectedObject, XElement propertyElement, IClassInfoGraphNode classInfoGraphNode, XElement root, ElementSchema elementSchema) { var memberInfo = typeInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var theObject = (XPBaseObject)memberInfo.GetValue(selectedObject); CreateRefElelement(classInfoGraphNode, theObject?.GetType() ?? memberInfo.MemberType, root, theObject, propertyElement, elementSchema); } }
void CreateCollectionProperty(ITypeInfo typeInfo, object selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root, XElement propertyElement, ElementSchema elementSchema) { var memberInfo = typeInfo.FindMember(classInfoGraphNode.Name); if (memberInfo?.GetValue(selectedObject) is IEnumerable theObjects) { foreach (var theObject in theObjects) { CreateRefElelement(classInfoGraphNode, theObject.GetType(), root, theObject, propertyElement, elementSchema); } } }
void CreateObjectProperty(XPBaseObject selectedObject, XElement propertyElement, IClassInfoGraphNode classInfoGraphNode, XElement root) { XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var theObject = (XPBaseObject)memberInfo.GetValue(selectedObject); CreateRefElelement(classInfoGraphNode, theObject != null ? theObject.GetType().Name : memberInfo.MemberType.Name, root, theObject, propertyElement); } }
void CreateRefElelement(IClassInfoGraphNode classInfoGraphNode, string typeName, XElement root, XPBaseObject theObject, XElement propertyElement) { var serializedObjectRefElement = new XElement("SerializedObjectRef"); propertyElement.Add(serializedObjectRefElement); serializedObjectRefElement.Add(new XAttribute("type", typeName)); serializedObjectRefElement.Add(new XAttribute("strategy", classInfoGraphNode.SerializationStrategy)); if (theObject != null) { IEnumerable<IClassInfoGraphNode> classInfoGraphNodes = GetClassInfoGraphNodes(theObject, typeName); createRefKeyElements(classInfoGraphNodes, theObject, serializedObjectRefElement); if (serializedObjectRefElement.FindObjectFromRefenceElement(true) == null &&classInfoGraphNode.SerializationStrategy == SerializationStrategy.SerializeAsObject) ExportCore(theObject, classInfoGraphNodes, root); } }
void CreateCollectionProperty(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root, XElement propertyElement) { XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var theObjects = (IEnumerable)memberInfo.GetValue(selectedObject); foreach (XPBaseObject theObject in theObjects) { CreateRefElelement(classInfoGraphNode, theObject.GetType().Name, root, theObject, propertyElement); } } }
void CreateRefElelement(IClassInfoGraphNode classInfoGraphNode, string typeName, XElement root, XPBaseObject theObject, XElement propertyElement) { var serializedObjectRefElement = new XElement("SerializedObjectRef"); propertyElement.Add(serializedObjectRefElement); serializedObjectRefElement.Add(new XAttribute("type", typeName)); serializedObjectRefElement.Add(new XAttribute("strategy", classInfoGraphNode.SerializationStrategy)); if (theObject != null) { IEnumerable <IClassInfoGraphNode> classInfoGraphNodes = _serializeClassInfoGraphNodesCalculator.GetSerializedClassInfoGraphNodes(theObject, typeName); CreateRefKeyElements(classInfoGraphNodes, theObject, serializedObjectRefElement); if (classInfoGraphNode.SerializationStrategy == SerializationStrategy.SerializeAsObject) { ExportCore(theObject, classInfoGraphNodes, root); } } }
void SetMemberValue(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement propertyElement) { var memberValue = selectedObject.GetMemberValue(classInfoGraphNode.Name); var xpMemberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (xpMemberInfo != null ) { if (xpMemberInfo.Converter != null) memberValue = (xpMemberInfo.Converter.ConvertToStorageType(memberValue)); if (memberValue is byte[]) memberValue = Convert.ToBase64String((byte[])memberValue); if (memberValue is DateTime) memberValue = ((DateTime)memberValue).Ticks; if (memberValue is string) propertyElement.Add(new XCData(memberValue.ToString())); else { propertyElement.Value = GetInvariantValue(memberValue); } } }
XElement GetPropertyElement(XElement serializedObjectElement, IClassInfoGraphNode classInfoGraphNode, ElementSchema elementSchema) { var propertyElement = new XElement(elementSchema.Property); serializedObjectElement.Add(propertyElement); if ((_minifyOutput && classInfoGraphNode.NodeType != NodeType.Simple) || !_minifyOutput) { propertyElement.Add(new XAttribute(elementSchema.Type, classInfoGraphNode.NodeType.ToString().FirstCharacterToLower())); } propertyElement.Add(new XAttribute(elementSchema.Name, classInfoGraphNode.Name)); if ((_minifyOutput && classInfoGraphNode.Key) || !_minifyOutput) { propertyElement.Add(new XAttribute(elementSchema.IsKey, classInfoGraphNode.Key)); } return(propertyElement); }
void CreateRefElelement(IClassInfoGraphNode classInfoGraphNode, Type objectType, XElement root, object theObject, XElement propertyElement, ElementSchema elementSchema) { var serializedObjectRefElement = new XElement(elementSchema.SerializedObjectRef); propertyElement.Add(serializedObjectRefElement); serializedObjectRefElement.Add(new XAttribute(elementSchema.Type, objectType.Name)); serializedObjectRefElement.Add(new XAttribute(elementSchema.Strategy, classInfoGraphNode.SerializationStrategy)); if (theObject != null) { var classInfoGraphNodes = _serializeClassInfoGraphNodesCalculator.GetSerializedClassInfoGraphNodes(theObject, objectType.Name).ToArray(); CreateRefKeyElements(XafTypesInfo.CastTypeToTypeInfo(objectType), classInfoGraphNodes, theObject, serializedObjectRefElement, elementSchema); if (classInfoGraphNode.SerializationStrategy == SerializationStrategy.SerializeAsObject) { ExportCore(theObject, classInfoGraphNodes, root, elementSchema); } } }
void SetMemberValue(ITypeInfo typeInfo, object theObject, IClassInfoGraphNode classInfoGraphNode, XElement propertyElement) { var memberInfo = typeInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var memberValue = memberInfo.GetValue(theObject); var valueConverter = memberInfo.FindAttribute <ValueConverterAttribute>(); if (valueConverter != null) { memberValue = (valueConverter.Converter.ConvertToStorageType(memberValue)); } if (memberValue is byte[]) { memberValue = Convert.ToBase64String((byte[])memberValue); } if (memberValue is DateTime) { memberValue = ((DateTime)memberValue).Ticks; } if ((_minifyOutput && !memberInfo.HasDefaultValue(memberValue)) || !_minifyOutput) { if (memberValue is string) { memberValue = IAFModule.SanitizeXmlString((string)memberValue); propertyElement.Add(new XCData(memberValue.ToString())); } else { propertyElement.Value = GetInvariantValue(memberValue); } } else { propertyElement.Remove(); } } }
void CreateObjectProperty(XPBaseObject selectedObject, XElement propertyElement, IClassInfoGraphNode classInfoGraphNode, XElement root) { XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var theObject = (XPBaseObject) memberInfo.GetValue(selectedObject); CreateRefElelement(classInfoGraphNode,theObject!= null?theObject.GetType().Name:memberInfo.MemberType.Name, root, theObject, propertyElement); } }
void CreateCollectionProperty(XPBaseObject selectedObject, IClassInfoGraphNode classInfoGraphNode, XElement root, XElement propertyElement) { XPMemberInfo memberInfo = selectedObject.ClassInfo.FindMember(classInfoGraphNode.Name); if (memberInfo != null) { var theObjects = (IEnumerable)memberInfo.GetValue(selectedObject); foreach (XPBaseObject theObject in theObjects) { CreateRefElelement(classInfoGraphNode,theObject.GetType().Name, root, theObject, propertyElement); } } }