Exemplo n.º 1
0
 /// <summary>
 /// Convert the object into a binary representation of a DataField
 /// </summary>
 /// <param name="obj">The object to encode.</param>
 /// <returns>The bytes representing the object in DataFrame format.</returns>
 /// <exception cref="ArgumentException">if the object cannot be encoded - type not supported</exception>
 public static byte[] Encode(object obj)
 {
     return(DataField.Encode(obj, DataField.GetType(obj)));
 }
Exemplo n.º 2
0
 /// <summary>
 /// The constructor for the most common use case, Name-Value pair
 /// </summary>
 /// <param name="name">The name of this DataField</param>
 /// <param name="obj">The object value to encode</param>
 /// <exception cref="ArgumentException">If the name is not valid or the object type is not supported</exception>
 public DataField(string name, object obj)
 {
     this.name = DataField.NameCheck(name);
     type      = DataField.GetType(obj);
     value     = DataField.Encode(obj, type);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a DataField with a specified name, type and value.
 /// </summary>
 /// <remarks>
 /// <para>It is possible to use this to force a data field into a specific type even if the value is null.</para>
 /// </remarks>
 /// <param name="name">The name of this DataField</param>
 /// <param name="type">The type code representing the type of data held.</param>
 /// <param name="value">The encoded value of the field. An empty array is equivalent to a null value.</param>
 /// <exception cref="ArgumentException">If there are problems with the name</exception>
 public DataField(string name, byte type, byte[] value)
 {
     this.name  = DataField.NameCheck(name);
     this.type  = type;
     this.value = value;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a DataField for the specific object.
 /// </summary>
 /// <param name="obj">The object to use as the value of the field</param>
 /// <exception cref="ArgumentException">If the object type is not supported</exception>
 public DataField(object obj)
 {
     type  = DataField.GetType(obj);
     value = DataField.Encode(obj, type);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Convenience constructor for a frame wrapping the given field.
 /// </summary>
 /// <param name="field">the field to place in this frame </param>
 public DataFrame(DataField field) : this()
 {
     fields.Add(field);
 }