Ejemplo n.º 1
0
 /// <summary>
 /// Convert encodeable to binary
 /// </summary>
 /// <param name="encodeable"></param>
 /// <param name="context"></param>
 /// <returns></returns>
 public static byte[] AsBinary(this IEncodeable encodeable,
                               IServiceMessageContext context)
 {
     using (var stream = new MemoryStream()) {
         using (var encoder = new BinaryEncoder(stream, context)) {
             encodeable.Encode(encoder);
         }
         return(stream.ToArray());
     }
 }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 public void WriteEncodeable(string property, IEncodeable value, Type systemType)
 {
     if (value == null)
     {
         WriteNull(property);
     }
     else
     {
         PushObject(property);
         if (value != null)
         {
             value.Encode(this);
         }
         PopObject();
     }
 }
        /// <summary>
        /// Writes an encodeable object to the stream.
        /// </summary>
        public void WriteEncodeable(string fieldName, IEncodeable value, System.Type systemType)
        {            
            if (BeginField(fieldName, value == null, true))
            {
                if (value != null)
                {
                    value.Encode(this);
                }

                EndField(fieldName);
            }
        }      
Ejemplo n.º 4
0
        /// <summary>
        /// Writes an encodeable object to the stream.
        /// </summary>
        public void WriteEncodeable(string fieldName, IEncodeable value, System.Type systemType)
        {
            if (value == null)
            {
                WriteSimpleField(fieldName, null, false);
                return;
            }

            PushStructure(fieldName);

            if (value != null)
            {
                value.Encode(this);
            }

            PopStructure();
        }