public static FaultResponse GetFromXml(XElement element) { XElement changedParamsMessageElement = new XElement(element); changedParamsMessageElement.Descendants("int").ToList().ForEach(localElement => localElement.Name = "i4"); FaultResponseEventArgsContainer result = new FaultResponseEventArgsContainer(); List <XElement> paramElements = new List <XElement> { changedParamsMessageElement }; List <RPCParamInfo> parameters = RPCParamInfo.GetFromType(typeof(FaultResponseEventArgsContainer), RPCParamInfo.RevtrievalMode.OnlyWithIndexes); RPCCommand.GetParameterElementInstance(parameters, 0, paramElements[0], result); return(result.Fault); }
public static List <RPCParamInfo> GetFromType(Type type, RevtrievalMode revtrievalMode) { List <RPCParamInfo> result = new List <RPCParamInfo>(); foreach (PropertyInfo propertyInfo in type.GetProperties()) { RPCParamAttribute[] attributes = (RPCParamAttribute[])propertyInfo.GetCustomAttributes(typeof(RPCParamAttribute), false); if (attributes.Length == 0) { continue; } RPCParamAttribute attribute = attributes[0]; if (revtrievalMode == RevtrievalMode.OnlyWithIndexes && attribute.MemberName != null) { continue; } if (revtrievalMode == RevtrievalMode.OnlyWithMemberName && attribute.MemberName == null) { continue; } RPCParamInfo paramInfo = new RPCParamInfo(); paramInfo.Index = attribute.Index; paramInfo.MemberName = attribute.MemberName; paramInfo.PropertyInfo = propertyInfo; result.Add(paramInfo); } result.Sort((x, y) => x.Index - y.Index); return(result); }