/// <summary> /// Read element value /// </summary> /// <param name="t">Expected type of the element</param> /// <param name="node">XmlNode to be read from</param> /// <returns>Value of element</returns> private T ReadObject <T>(XmlNode node) { Type type = typeof(T); if (typeof(IMwsObject).IsAssignableFrom(type)) { T mwsObject = MwsUtil.NewInstance <T>(); BeginObject(node); (mwsObject as IMwsObject).ReadFragmentFrom(this); EndObject(); return(mwsObject); } else if (type == typeof(object)) { return((T)(object)node); } else { return(ConvertValue <T>(node.InnerText)); } }
/// <summary> /// Creates a MwsCall and sends the request /// </summary> /// <typeparam name="T"></typeparam> /// <param name="type"></param> /// <param name="requestData"></param> /// <returns></returns> public T Call <T>(IMwsRequestType <T> type, IMwsObject requestData) where T : IMwsObject { IMwsReader responseReader = null; try { string servicePath = type.ServicePath; string operationName = type.OperationName; IMwsCall mc = NewCall(servicePath, operationName); requestData.WriteFragmentTo(mc); responseReader = mc.invoke(); MwsResponseHeaderMetadata rhmd = mc.GetResponseMetadataHeader(); T response = MwsUtil.NewInstance <T>(); type.SetResponseHeaderMetadata(response, rhmd); response.ReadFragmentFrom(responseReader); return(response); } catch (Exception e) { throw type.WrapException(e); } }