public Key(FieldType type, bool inclusive) { this.type = type; this.inclusion = inclusive?1:0; }
/// <summary> Constructor of key with given value and specified target type /// </summary> /// <param name="v">key value /// </param> /// <param name="t">target key type /// </param> /// <param name="inclusive">whether boundary is inclusive or exclusive /// </param> public Key(object v, Type t, bool inclusive) { inclusion = inclusive?1:0; if (t.Equals(typeof(long))) { type = ClassDescriptor.FieldType.tpLong; lval = Convert.ToInt64(v); } else if (t.Equals(typeof(int))) { type = ClassDescriptor.FieldType.tpInt; ival = Convert.ToInt32(v); } else if (t.Equals(typeof(sbyte))) { type = ClassDescriptor.FieldType.tpSByte; #if COMPACT_NET_FRAMEWORK ival = (sbyte)Convert.ToInt32(v); #else ival = Convert.ToSByte(v); #endif } else if (t.Equals(typeof(short))) { type = ClassDescriptor.FieldType.tpShort; #if COMPACT_NET_FRAMEWORK ival = (short)Convert.ToInt32(v); #else ival = Convert.ToInt16(v); #endif } else if (t.Equals(typeof(ulong))) { type = ClassDescriptor.FieldType.tpULong; lval = (long)Convert.ToUInt64(v); } else if (t.Equals(typeof(uint))) { type = ClassDescriptor.FieldType.tpUInt; ival = (int)Convert.ToUInt32(v); } else if (t.Equals(typeof(byte))) { type = ClassDescriptor.FieldType.tpByte; #if COMPACT_NET_FRAMEWORK ival = (byte)Convert.ToInt32(v); #else ival = Convert.ToByte(v); #endif } else if (t.Equals(typeof(ushort))) { type = ClassDescriptor.FieldType.tpUShort; ival = Convert.ToUInt16(v); } else if (t.Equals(typeof(char))) { type = ClassDescriptor.FieldType.tpChar; ival = Convert.ToChar(v); } else if (t.Equals(typeof(float))) { type = ClassDescriptor.FieldType.tpFloat; dval = Convert.ToSingle(v); } else if (t.Equals(typeof(double))) { type = ClassDescriptor.FieldType.tpDouble; dval = Convert.ToDouble(v); } else if (t.Equals(typeof(bool))) { type = ClassDescriptor.FieldType.tpBoolean; ival = (bool)v ? 1 : 0; } else if (t.Equals(typeof(string))) { type = ClassDescriptor.FieldType.tpString; oval = v.ToString(); } else if (t.Equals(typeof(DateTime))) { type = ClassDescriptor.FieldType.tpDate; lval = ((DateTime)v).Ticks; } else if (t.Equals(typeof(Guid))) { type = ClassDescriptor.FieldType.tpGuid; guid = (Guid)v; } else if (t.Equals(typeof(decimal))) { type = ClassDescriptor.FieldType.tpDecimal; dec = (decimal)v; } #if WINRT_NET_FRAMEWORK else if (t.Equals(typeof(Enum)) || t.GetTypeInfo().IsEnum) #else else if (t.Equals(typeof(Enum)) || t.IsEnum) #endif { type = ClassDescriptor.FieldType.tpEnum; ival = Convert.ToInt32(v); } else { type = ClassDescriptor.FieldType.tpObject; oval = v; } }
internal Key(FieldType type, int oid) { this.type = type; ival = oid; this.inclusion = 1; }
internal Key(FieldType type, bool inclusive) { this.type = type; this.inclusion = inclusive?1:0; }