示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BoundProperty{T}"/> class
 /// with the specified bindable property.
 /// </summary>
 /// <param name="source">The bindable property that is bound.</param>
 public BoundProperty(BindableProperty <T> source) : base(source.GetValue())
 {
     Bind(source);
 }
示例#2
0
 internal static byte[] SerializePropertyValue(BindableProperty property, DataRowEntity row)
 {
     using (var ms = new MemoryStream())
     {
         using (var pw = ProtoBufExtention.CreateProtoWriterSimplely(ms))
         {
             var o = property.GetValue(row);
             if (property.PropertyType == typeof(TimeSpan))
                 pw.WriteSimplely((TimeSpan)o);
             else
             {
                 switch (Type.GetTypeCode(property.PropertyType))
                 {
                     case TypeCode.Boolean:
                         pw.WriteSimplely((bool)o);
                         break;
                     case TypeCode.Byte:
                         pw.WriteSimplely((byte)o);
                         break;
                     case TypeCode.Char:
                         pw.WriteSimplely((char)o);
                         break;
                     case TypeCode.DateTime:
                         pw.WriteSimplely((DateTime)o);
                         break;
                     case TypeCode.Double:
                         pw.WriteSimplely((double)o);
                         break;
                     case TypeCode.Int16:
                         pw.WriteSimplely((short)o);
                         break;
                     case TypeCode.Int32:
                         pw.WriteSimplely((int)o);
                         break;
                     case TypeCode.Int64:
                         pw.WriteSimplely((long)o);
                         break;
                     case TypeCode.SByte:
                         pw.WriteSimplely((sbyte)o);
                         break;
                     case TypeCode.Single:
                         pw.WriteSimplely((float)o);
                         break;
                     case TypeCode.String:
                         pw.WriteSimplely((string)o);
                         break;
                     case TypeCode.UInt16:
                         pw.WriteSimplely((ushort)o);
                         break;
                     case TypeCode.UInt32:
                         pw.WriteSimplely((uint)o);
                         break;
                     case TypeCode.UInt64:
                         pw.WriteSimplely((ulong)o);
                         break;
                 }
             }
         }
         return ms.ToArray();
     }
 }
 public void then_new_value_is_set_on_bindable()
 {
     Assert.AreEqual("NewValue", bindable.GetValue(null));
 }