/// <summary> /// Serialises the object to XML. /// </summary> /// <returns></returns> public byte[] ToXmlBytes() { // It is an error if parameters are defined for Cancel or GetStatus request object proxy = null; switch (Operation) { case TaskOperationType.Submit: // Creating the proxy object var proxySubmit = new XsdNs.SubmitType(); // Nothing to add to proxy here! // Adding the fields common with "update" PopulateTaskingRequestProxy(proxySubmit); proxy = proxySubmit; break; case TaskOperationType.Update: // Creating the proxy object var proxyUpdate = new XsdNs.UpdateType() { targetTask = TaskId }; // Adding the fields common with "submit" PopulateTaskingRequestProxy(proxyUpdate); proxy = proxyUpdate; break; case TaskOperationType.GetStatus: proxy = CreateGetStatusProxy(); break; case TaskOperationType.Cancel: proxy = CreateCancelProxy(); break; default: throw new NotSupportedException("Unsupported task operation " + Operation.ToString()); } try { // Serialising return(XNeut.Helper.ToXmlBytes(proxy)); } catch (InvalidOperationException e) { throw new XNeut.InvalidMessageException("XML serialisation failed", e); } }
private void ReadUpdateXml(byte[] xmlBytes) { XsdNs.UpdateType proxy = null; try { // Deserialising proxy = (XsdNs.UpdateType)XNeut.Helper.DeserialiseFromXml(typeof(XsdNs.UpdateType), xmlBytes); } catch (InvalidOperationException e) { throw new XNeut.InvalidMessageException("Failed to deserialise update task request from XML", e); } ReadTaskingRequestItemsFromProxy(proxy); // Assigning the fields specific to this subclass TaskId = proxy.targetTask; }