public IPacketContentReader GetReader(IPacketContent content, Type actualType) { Contract.Requires <ArgumentNullException>(content != null); Contract.Requires <ArgumentNullException>(actualType != null); Contract.Ensures(Contract.Result <IPacketContentReader>() != null); return(default(IPacketContentReader)); }
private IPacketContent DeserializeContent(Type contentType, XmlReader xmlReader) { IPacketContent content = Activator.CreateInstance(contentType) as IPacketContent; while (xmlReader.MoveToNextAttribute()) { content.SetProperty(xmlReader.Name, xmlReader.Value); } return(content); }
private void SerializeContent(IPacketContent message, XmlWriter xmlWriter) { xmlWriter.WriteStartElement(message.GetType().Name); var simples = message.GetProperties(); if (simples != null) { foreach (var attribute in message.GetProperties()) { xmlWriter.WriteAttributeString(attribute.Key, attribute.Value); } } xmlWriter.WriteEndElement(); }
public IPacketContentReader GetReader(IPacketContent content, Type actualType) { return(content.ContentType == "application/octet-stream" ? (IPacketContentReader) new BinaryContentReader(content.GetBodyStream(), actualType) : new JsonContentReader(content.GetBodyStream(), actualType)); }