public void SerializeRequest(Stream stm, XmlRpcRequest request) { var xtw = XmlRpcXmlWriter.Create(stm, XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement(string.Empty, "methodCall", string.Empty); { var mappingActions = new MappingActions(); mappingActions = GetTypeMappings(request.Mi, mappingActions); mappingActions = GetMappingActions(request.Mi, mappingActions); WriteFullElementString(xtw, "methodName", request.Method); if (request.Args.Length > 0 || UseEmptyParamsTag) { xtw.WriteStartElement("params"); try { if (!IsStructParamsMethod(request.Mi)) SerializeParams(xtw, request, mappingActions); else SerializeStructParams(xtw, request, mappingActions); } catch (XmlRpcUnsupportedTypeException ex) { throw new XmlRpcUnsupportedTypeException( ex.UnsupportedType, string.Format( "A parameter is of, or contains an instance of, type {0} which cannot be mapped to an XML-RPC type", ex.UnsupportedType)); } WriteFullEndElement(xtw); } } WriteFullEndElement(xtw); xtw.Flush(); }
void SerializeStructParams(XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { ParameterInfo[] pis = request.mi.GetParameters(); if (request.args.Length > pis.Length) { throw new XmlRpcInvalidParametersException("Number of request " + "parameters greater than number of proxy method parameters."); } if (Attribute.IsDefined(pis[request.args.Length - 1], typeof(ParamArrayAttribute))) { throw new XmlRpcInvalidParametersException("params parameter cannot " + "be used with StructParams."); } xtw.WriteStartElement("", "param", ""); xtw.WriteStartElement("", "value", ""); xtw.WriteStartElement("", "struct", ""); for (int i = 0; i < request.args.Length; i++) { if (request.args[i] == null) { throw new XmlRpcNullParameterException(String.Format( "Null method parameter #{0}", i + 1)); } xtw.WriteStartElement("", "member", ""); WriteFullElementString(xtw, "name", pis[i].Name); Serialize(xtw, request.args[i], mappingActions); WriteFullEndElement(xtw); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); WriteFullEndElement(xtw); }
public void SerializeResponse(Stream stm, XmlRpcResponse response) { Object ret = response.retVal; if (ret is XmlRpcFaultException) { SerializeFaultResponse(stm, (XmlRpcFaultException)ret); return; } XmlWriter xtw = XmlRpcXmlWriter.Create(stm, base.XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement("", "methodResponse", ""); xtw.WriteStartElement("", "params", ""); xtw.WriteStartElement("", "param", ""); var mappingActions = new MappingActions(); mappingActions = GetTypeMappings(response.MethodInfo, mappingActions); mappingActions = GetReturnMappingActions(response, mappingActions); try { Serialize(xtw, ret, mappingActions); } catch (XmlRpcUnsupportedTypeException ex) { throw new XmlRpcInvalidReturnType(string.Format( "Return value is of, or contains an instance of, type {0} which " + "cannot be mapped to an XML-RPC type", ex.UnsupportedType)); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); WriteFullEndElement(xtw); xtw.Flush(); }
//#endif void Serialize( XmlWriter xtw, Object o, MappingActions mappingActions) { Serialize(xtw, o, mappingActions, new List <object>()); }
void BuildArrayXml( XmlWriter xtw, Array ary, int CurRank, int[] indices, MappingActions mappingActions, List <object> nestedObjs) { xtw.WriteStartElement("", "array", ""); xtw.WriteStartElement("", "data", ""); if (CurRank < (ary.Rank - 1)) { for (int i = 0; i < ary.GetLength(CurRank); i++) { indices[CurRank] = i; xtw.WriteStartElement("", "value", ""); BuildArrayXml(xtw, ary, CurRank + 1, indices, mappingActions, nestedObjs); WriteFullEndElement(xtw); } } else { for (int i = 0; i < ary.GetLength(CurRank); i++) { indices[CurRank] = i; Serialize(xtw, ary.GetValue(indices), mappingActions, nestedObjs); } } WriteFullEndElement(xtw); WriteFullEndElement(xtw); }
protected MappingActions GetMappingActions(ICustomAttributeProvider cap, MappingActions mappingActions) { if (cap == null) { return(mappingActions); } var ret = new MappingActions { EnumMapping = mappingActions.EnumMapping, NullMappingAction = mappingActions.NullMappingAction }; var nullMappingAttr = GetAttribute <XmlRpcNullMappingAttribute>(cap); if (nullMappingAttr != null) { ret.NullMappingAction = nullMappingAttr.Action; } else { // check for missing mapping attribute for backwards compatibility var missingAttr = GetAttribute <XmlRpcMissingMappingAttribute>(cap); if (missingAttr != null) { ret.NullMappingAction = MapToNullMappingAction(missingAttr.Action); } } var enumAttr = GetAttribute <XmlRpcEnumMappingAttribute>(cap); if (enumAttr != null) { ret.EnumMapping = ((XmlRpcEnumMappingAttribute)enumAttr).Mapping; } return(ret); }
public void SerializeResponse(Stream stm, XmlRpcResponse response) { Object ret = response.retVal; if (ret is XmlRpcFaultException) { SerializeFaultResponse(stm, (XmlRpcFaultException)ret); return; } XmlWriter xtw = XmlRpcXmlWriter.Create(stm, base.XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement("", "methodResponse", ""); xtw.WriteStartElement("", "params", ""); xtw.WriteStartElement("", "param", ""); var mappingActions = new MappingActions(); mappingActions = GetTypeMappings(response.MethodInfo, mappingActions); mappingActions = GetReturnMappingActions(response, mappingActions); try { Serialize(xtw, ret, mappingActions); } catch (XmlRpcUnsupportedTypeException ex) { throw new XmlRpcInvalidReturnType(string.Format( "Return value is of, or contains an instance of, type {0} which " + "cannot be mapped to an XML-RPC type", ex.UnsupportedType)); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); WriteFullEndElement(xtw); xtw.Flush(); }
MappingActions GetReturnMappingActions(XmlRpcResponse response, MappingActions mappingActions) { var ri = response.MethodInfo != null ? response.MethodInfo.ReturnParameter : null; return(GetMappingActions(ri, mappingActions)); }
private void SerializeMultiDimensionalArray( XmlWriter xtw, object o, MappingActions mappingActions, List <object> nestedObjs) { var mda = (Array)o; var indices = new int[mda.Rank]; BuildArrayXml(xtw, mda, 0, indices, mappingActions, nestedObjs); }
protected MappingActions GetTypeMappings(MethodInfo mi, MappingActions mappingActions) { if (mi != null) { var declaringType = mi != null ? mi.DeclaringType : null; foreach (Type itf in declaringType.GetInterfaces()) { mappingActions = GetMappingActions(itf, mappingActions); } mappingActions = GetMappingActions(declaringType, mappingActions); } return(mappingActions); }
private void SerializeArray(XmlWriter xtw, object o, MappingActions mappingActions, List <object> nestedObjs) { xtw.WriteStartElement(string.Empty, "array", string.Empty); xtw.WriteStartElement(string.Empty, "data", string.Empty); var a = (Array)o; foreach (var aobj in a) { Serialize(xtw, aobj, mappingActions, nestedObjs); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); }
private void SerializeInt32(XmlWriter xtw, object o, MappingActions mappingActions) { if (o.GetType().IsEnum) { if (mappingActions.EnumMapping == EnumMapping.String) { SerializeString(xtw, o.ToString()); return; } o = Convert.ToInt32(o); } WriteFullElementString(xtw, UseIntTag ? "int" : "i4", o.ToString()); }
public static XmlReader Serialize( string testName, object obj, Encoding encoding, MappingActions actions) { Stream stm = new MemoryStream(); XmlWriter xtw = XmlRpcXmlWriter.Create(stm, new XmlRpcFormatSettings()); xtw.WriteStartDocument(); XmlRpcSerializer ser = new XmlRpcSerializer(); ser.Serialize(xtw, obj, actions); xtw.Flush(); stm.Position = 0; XmlReader rdr = XmlRpcXmlReader.Create(stm); return rdr; }
private Object SerializeInt64(XmlWriter xtw, Object o, MappingActions mappingActions) { if (o.GetType().IsEnum) { if (mappingActions.EnumMapping == EnumMapping.String) { SerializeString(xtw, o.ToString()); } else { o = Convert.ToInt64(o); } } WriteFullElementString(xtw, "i8", o.ToString()); return(o); }
void SerializeParams(XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { ParameterInfo[] pis = null; if (request.mi != null) { pis = request.mi.GetParameters(); } for (int i = 0; i < request.args.Length; i++) { var paramMappingActions = pis == null ? mappingActions : GetMappingActions(pis[i], mappingActions); if (pis != null) { if (i >= pis.Length) { throw new XmlRpcInvalidParametersException("Number of request " + "parameters greater than number of proxy method parameters."); } if (i == pis.Length - 1 && Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute))) { Array ary = (Array)request.args[i]; foreach (object o in ary) { //if (o == null) // throw new XmlRpcNullParameterException( // "Null parameter in params array"); xtw.WriteStartElement("", "param", ""); Serialize(xtw, o, paramMappingActions); WriteFullEndElement(xtw); } break; } } //if (request.args[i] == null) //{ // throw new XmlRpcNullParameterException(String.Format( // "Null method parameter #{0}", i + 1)); //} xtw.WriteStartElement("", "param", ""); Serialize(xtw, request.args[i], paramMappingActions); WriteFullEndElement(xtw); } }
private void SerializeProperty( XmlWriter xtw, object o, List <object> nestedObjs, MemberInfo mi, MappingActions structActions) { var pi = (PropertyInfo)mi; var member = pi.Name; var attrchk = Attribute.GetCustomAttribute(pi, typeof(XmlRpcMemberAttribute)); var attribute = attrchk as XmlRpcMemberAttribute; if (attribute != null) { var mmbr = attribute.Member; if (mmbr != string.Empty) { member = mmbr; } } var memberActions = MemberMappingActions(o.GetType(), pi.Name, structActions); if (pi.GetValue(o, null) == null) { switch (memberActions.NullMappingAction) { case NullMappingAction.Ignore: return; case NullMappingAction.Error: throw new XmlRpcMappingSerializeException( string.Format( @"Member ""{0}"" of struct ""{1}"" cannot be null.", member, o.GetType().Name)); } } xtw.WriteStartElement(string.Empty, "member", string.Empty); WriteFullElementString(xtw, "name", member); Serialize(xtw, pi.GetValue(o, null), memberActions, nestedObjs); WriteFullEndElement(xtw); }
void SerializeParams(XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { ParameterInfo[] pis = null; if (request.mi != null) { pis = request.mi.GetParameters(); } for (int i = 0; i < request.args.Length; i++) { var paramMappingActions = pis == null ? mappingActions : GetMappingActions(pis[i], mappingActions); if (pis != null) { if (i >= pis.Length) throw new XmlRpcInvalidParametersException("Number of request " + "parameters greater than number of proxy method parameters."); if (i == pis.Length - 1 && Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute))) { Array ary = (Array)request.args[i]; foreach (object o in ary) { //if (o == null) // throw new XmlRpcNullParameterException( // "Null parameter in params array"); xtw.WriteStartElement("", "param", ""); Serialize(xtw, o, paramMappingActions); WriteFullEndElement(xtw); } break; } } //if (request.args[i] == null) //{ // throw new XmlRpcNullParameterException(String.Format( // "Null method parameter #{0}", i + 1)); //} xtw.WriteStartElement("", "param", ""); Serialize(xtw, request.args[i], paramMappingActions); WriteFullEndElement(xtw); } }
void SerializeParams( XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { ParameterInfo[] pis = null; if (request.Mi != null) { pis = request.Mi.GetParameters(); } for (var i = 0; i < request.Args.Length; i++) { var paramMappingActions = pis == null ? mappingActions : GetMappingActions(pis[i], mappingActions); if (pis != null) { if (i >= pis.Length) { throw new XmlRpcInvalidParametersException( "Number of request parameters greater than number of proxy method parameters."); } if (i == pis.Length - 1 && Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute))) { var ary = (Array)request.Args[i]; foreach (var o in ary) { xtw.WriteStartElement("", "param", ""); Serialize(xtw, o, paramMappingActions); WriteFullEndElement(xtw); } break; } } xtw.WriteStartElement("", "param", ""); Serialize(xtw, request.Args[i], paramMappingActions); WriteFullEndElement(xtw); } }
MappingActions MemberMappingActions( Type type, string memberName, MappingActions currentActions) { // if struct member has mapping action attribute, override the current // mapping action else just return the current action if (type == null) { return(currentActions); } MemberInfo[] mis = type.GetMember(memberName); if (mis == null || mis.Length == 0) { return(currentActions); } var ret = GetMappingActions(mis[0], currentActions); return(ret); }
protected MappingActions GetTypeMappings(MethodInfo mi, MappingActions mappingActions) { if (mi == null) { return(mappingActions); } var declaringType = mi.DeclaringType; if (declaringType == null) { return(mappingActions); } mappingActions = declaringType .GetInterfaces() .Aggregate(mappingActions, (current, itf) => GetMappingActions(itf, current)); return(GetMappingActions(declaringType, mappingActions)); }
public void SerializeRequest(Stream stm, XmlRpcRequest request) { var xtw = XmlRpcXmlWriter.Create(stm, XmlRpcFormatSettings); xtw.WriteStartDocument(); xtw.WriteStartElement(string.Empty, "methodCall", string.Empty); { var mappingActions = new MappingActions(); mappingActions = GetTypeMappings(request.Mi, mappingActions); mappingActions = GetMappingActions(request.Mi, mappingActions); WriteFullElementString(xtw, "methodName", request.Method); if (request.Args.Length > 0 || UseEmptyParamsTag) { xtw.WriteStartElement("params"); try { if (!IsStructParamsMethod(request.Mi)) { SerializeParams(xtw, request, mappingActions); } else { SerializeStructParams(xtw, request, mappingActions); } } catch (XmlRpcUnsupportedTypeException ex) { throw new XmlRpcUnsupportedTypeException( ex.UnsupportedType, string.Format( "A parameter is of, or contains an instance of, type {0} which cannot be mapped to an XML-RPC type", ex.UnsupportedType)); } WriteFullEndElement(xtw); } } WriteFullEndElement(xtw); xtw.Flush(); }
private void SerializeStruct(XmlWriter xtw, object o, MappingActions mappingActions, List <object> nestedObjs) { var structActions = GetMappingActions(o.GetType(), mappingActions); xtw.WriteStartElement(string.Empty, "struct", string.Empty); var mis = o.GetType().GetMembers(); foreach (var mi in mis.Where(mi => !Attribute.IsDefined(mi, typeof(NonSerializedAttribute)))) { switch (mi.MemberType) { case MemberTypes.Field: SerializeField(xtw, o, nestedObjs, mi, structActions); break; case MemberTypes.Property: SerializeProperty(xtw, o, nestedObjs, mi, structActions); break; } } WriteFullEndElement(xtw); }
private void SerializeHashTable( XmlWriter xtw, object o, MappingActions mappingActions, List <object> nestedObjs) { xtw.WriteStartElement(string.Empty, "struct", string.Empty); var xrs = o as XmlRpcStruct; if (xrs == null) { return; } foreach (var skey in from object obj in xrs.Keys select obj as string) { xtw.WriteStartElement(string.Empty, "member", string.Empty); WriteFullElementString(xtw, "name", skey); Serialize(xtw, xrs[skey], mappingActions, nestedObjs); WriteFullEndElement(xtw); } WriteFullEndElement(xtw); }
void SerializeStructParams( XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { var pis = request.Mi.GetParameters(); if (request.Args.Length > pis.Length) throw new XmlRpcInvalidParametersException( "Number of request parameters greater than number of proxy method parameters."); if (Attribute.IsDefined(pis[request.Args.Length - 1], typeof(ParamArrayAttribute))) { throw new XmlRpcInvalidParametersException( "params parameter cannot be used with StructParams."); } xtw.WriteStartElement("", "param", ""); xtw.WriteStartElement("", "value", ""); xtw.WriteStartElement("", "struct", ""); for (int i = 0; i < request.Args.Length; i++) { if (request.Args[i] == null) { throw new XmlRpcNullParameterException( string.Format( "Null method parameter #{0}", i + 1)); } xtw.WriteStartElement("", "member", ""); WriteFullElementString(xtw, "name", pis[i].Name); Serialize(xtw, request.Args[i], mappingActions); WriteFullEndElement(xtw); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); WriteFullEndElement(xtw); }
private static MappingActions MemberMappingActions(Type type, string memberName, MappingActions currentActions) { Contract.Requires(type != null); Contract.Requires(memberName != null); Contract.Requires(currentActions != null); // if struct member has mapping action attribute, override the current // mapping action else just return the current action if (type == null) { return(currentActions); } var mis = type.GetMember(memberName); return(mis.Length == 0 ? currentActions : GetMappingActions(mis[0], currentActions)); }
MappingActions GetReturnMappingActions(XmlRpcResponse response, MappingActions mappingActions) { var ri = response.MethodInfo != null ? response.MethodInfo.ReturnParameter : null; return GetMappingActions(ri, mappingActions); }
public void Serialize(XmlWriter xtw, object o, MappingActions mappingActions, List <object> nestedObjs) { if (nestedObjs.Contains(o)) { throw new XmlRpcUnsupportedTypeException( nestedObjs[0].GetType(), "Cannot serialize recursive data structure"); } nestedObjs.Add(o); try { xtw.WriteStartElement(string.Empty, "value", string.Empty); var xmlRpcType = XmlRpcTypeInfo.GetXmlRpcType(o); switch (xmlRpcType) { case XmlRpcType.tArray: SerializeArray(xtw, o, mappingActions, nestedObjs); break; case XmlRpcType.tMultiDimArray: SerializeMultiDimensionalArray(xtw, o, mappingActions, nestedObjs); break; case XmlRpcType.tBase64: SerializeBase64(xtw, o); break; case XmlRpcType.tBoolean: SerializeBoolean(xtw, o); break; case XmlRpcType.tDateTime: SerializeDateTime(xtw, o); break; case XmlRpcType.tDouble: SerializeDouble(xtw, o); break; case XmlRpcType.tHashtable: SerializeHashTable(xtw, o, mappingActions, nestedObjs); break; case XmlRpcType.tInt32: SerializeInt32(xtw, o, mappingActions); break; case XmlRpcType.tInt64: SerializeInt64(xtw, o, mappingActions); break; case XmlRpcType.tString: SerializeString(xtw, o); break; case XmlRpcType.tStruct: SerializeStruct(xtw, o, mappingActions, nestedObjs); break; case XmlRpcType.tVoid: SerializeVoid(xtw); break; case XmlRpcType.tNil: SerializeNil(xtw); break; default: throw new XmlRpcUnsupportedTypeException(o.GetType()); } WriteFullEndElement(xtw); } catch (NullReferenceException) { throw new XmlRpcNullReferenceException("Attempt to serialize data " + "containing null reference"); } finally { nestedObjs.RemoveAt(nestedObjs.Count - 1); } }
public static XmlReader Serialize(string testName, object obj, Encoding encoding, MappingActions actions) { Stream stm = new MemoryStream(); var xtw = XmlRpcXmlWriter.Create(stm, new XmlRpcFormatSettings()); xtw.WriteStartDocument(); var ser = new XmlRpcSerializer(); ser.Serialize(xtw, obj, actions); xtw.Flush(); stm.Position = 0; return(XmlRpcXmlReader.Create(stm)); }
void SerializeParams( XmlWriter xtw, XmlRpcRequest request, MappingActions mappingActions) { ParameterInfo[] pis = null; if (request.Mi != null) pis = request.Mi.GetParameters(); for (var i = 0; i < request.Args.Length; i++) { var paramMappingActions = pis == null ? mappingActions : GetMappingActions(pis[i], mappingActions); if (pis != null) { if (i >= pis.Length) throw new XmlRpcInvalidParametersException( "Number of request parameters greater than number of proxy method parameters."); if (i == pis.Length - 1 && Attribute.IsDefined(pis[i], typeof(ParamArrayAttribute))) { var ary = (Array)request.Args[i]; foreach (var o in ary) { xtw.WriteStartElement("", "param", ""); Serialize(xtw, o, paramMappingActions); WriteFullEndElement(xtw); } break; } } xtw.WriteStartElement("", "param", ""); Serialize(xtw, request.Args[i], paramMappingActions); WriteFullEndElement(xtw); } }
//#endif void Serialize( XmlWriter xtw, Object o, MappingActions mappingActions, List <object> nestedObjs) { if (nestedObjs.Contains(o)) { throw new XmlRpcUnsupportedTypeException(nestedObjs[0].GetType(), "Cannot serialize recursive data structure"); } nestedObjs.Add(o); try { xtw.WriteStartElement("", "value", ""); XmlRpcType xType = XmlRpcTypeInfo.GetXmlRpcType(o); if (xType == XmlRpcType.tArray) { xtw.WriteStartElement("", "array", ""); xtw.WriteStartElement("", "data", ""); Array a = (Array)o; foreach (Object aobj in a) { //if (aobj == null) // throw new XmlRpcMappingSerializeException(String.Format( // "Items in array cannot be null ({0}[]).", //o.GetType().GetElementType())); Serialize(xtw, aobj, mappingActions, nestedObjs); } WriteFullEndElement(xtw); WriteFullEndElement(xtw); } else if (xType == XmlRpcType.tMultiDimArray) { Array mda = (Array)o; int[] indices = new int[mda.Rank]; BuildArrayXml(xtw, mda, 0, indices, mappingActions, nestedObjs); } else if (xType == XmlRpcType.tBase64) { byte[] buf = (byte[])o; xtw.WriteStartElement("", "base64", ""); xtw.WriteBase64(buf, 0, buf.Length); WriteFullEndElement(xtw); } else if (xType == XmlRpcType.tBoolean) { bool boolVal = (bool)o; if (boolVal) { WriteFullElementString(xtw, "boolean", "1"); } else { WriteFullElementString(xtw, "boolean", "0"); } } else if (xType == XmlRpcType.tDateTime) { DateTime dt = (DateTime)o; string sdt = dt.ToString(DateTimeFormat, DateTimeFormatInfo.InvariantInfo); WriteFullElementString(xtw, "dateTime.iso8601", sdt); } else if (xType == XmlRpcType.tDouble) { double doubleVal = (double)o; WriteFullElementString(xtw, "double", doubleVal.ToString(null, CultureInfo.InvariantCulture)); } else if (xType == XmlRpcType.tHashtable) { xtw.WriteStartElement("", "struct", ""); XmlRpcStruct xrs = o as XmlRpcStruct; foreach (object obj in xrs.Keys) { string skey = obj as string; xtw.WriteStartElement("", "member", ""); WriteFullElementString(xtw, "name", skey); Serialize(xtw, xrs[skey], mappingActions, nestedObjs); WriteFullEndElement(xtw); } WriteFullEndElement(xtw); } else if (xType == XmlRpcType.tInt32) { o = SerializeInt32(xtw, o, mappingActions); } else if (xType == XmlRpcType.tInt64) { o = SerializeInt64(xtw, o, mappingActions); } else if (xType == XmlRpcType.tString) { SerializeString(xtw, o); } else if (xType == XmlRpcType.tStruct) { MappingActions structActions = GetMappingActions(o.GetType(), mappingActions); xtw.WriteStartElement("", "struct", ""); MemberInfo[] mis = o.GetType().GetMembers(); foreach (MemberInfo mi in mis) { if (Attribute.IsDefined(mi, typeof(NonSerializedAttribute))) { continue; } if (mi.MemberType == MemberTypes.Field) { FieldInfo fi = (FieldInfo)mi; string member = fi.Name; Attribute attrchk = Attribute.GetCustomAttribute(fi, typeof(XmlRpcMemberAttribute)); if (attrchk != null && attrchk is XmlRpcMemberAttribute) { string mmbr = ((XmlRpcMemberAttribute)attrchk).Member; if (mmbr != "") { member = mmbr; } } MappingActions memberActions = MemberMappingActions(o.GetType(), fi.Name, structActions); if (fi.GetValue(o) == null) { if (memberActions.NullMappingAction == NullMappingAction.Ignore) { continue; } else if (memberActions.NullMappingAction == NullMappingAction.Error) { throw new XmlRpcMappingSerializeException(@"Member """ + member + @""" of struct """ + o.GetType().Name + @""" cannot be null."); } } xtw.WriteStartElement("", "member", ""); WriteFullElementString(xtw, "name", member); Serialize(xtw, fi.GetValue(o), memberActions, nestedObjs); WriteFullEndElement(xtw); } else if (mi.MemberType == MemberTypes.Property) { PropertyInfo pi = (PropertyInfo)mi; string member = pi.Name; Attribute attrchk = Attribute.GetCustomAttribute(pi, typeof(XmlRpcMemberAttribute)); if (attrchk != null && attrchk is XmlRpcMemberAttribute) { string mmbr = ((XmlRpcMemberAttribute)attrchk).Member; if (mmbr != "") { member = mmbr; } } MappingActions memberActions = MemberMappingActions(o.GetType(), pi.Name, structActions); if (pi.GetValue(o, null) == null) { if (memberActions.NullMappingAction == NullMappingAction.Ignore) { continue; } else if (memberActions.NullMappingAction == NullMappingAction.Error) { throw new XmlRpcMappingSerializeException(@"Member """ + member + @""" of struct """ + o.GetType().Name + @""" cannot be null."); } } xtw.WriteStartElement("", "member", ""); WriteFullElementString(xtw, "name", member); Serialize(xtw, pi.GetValue(o, null), memberActions, nestedObjs); WriteFullEndElement(xtw); } } WriteFullEndElement(xtw); } else if (xType == XmlRpcType.tVoid) { WriteFullElementString(xtw, "string", ""); } else if (xType == XmlRpcType.tNil) { xtw.WriteStartElement("nil"); WriteFullEndElement(xtw); } else { throw new XmlRpcUnsupportedTypeException(o.GetType()); } WriteFullEndElement(xtw); } catch (System.NullReferenceException) { throw new XmlRpcNullReferenceException("Attempt to serialize data " + "containing null reference"); } finally { nestedObjs.RemoveAt(nestedObjs.Count - 1); } }