Пример #1
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);
 }
Пример #2
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;
 }