Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 public IPacketContentReader GetReader(IPacketContent content, Type actualType)
 {
     return(content.ContentType == "application/octet-stream"
 ? (IPacketContentReader) new BinaryContentReader(content.GetBodyStream(), actualType)
 : new JsonContentReader(content.GetBodyStream(), actualType));
 }