Example #1
0
 public DecimalDataType(int id, string name, string alias, DataType basic, DataType parent, bool editable,
     int precision, int scale, bool nullable)
     : base(id, name, alias, basic, parent, editable, nullable)
 {
     this.precision = precision;
     this.scale = scale;
 }
Example #2
0
 public BinaryDataType(int id, string name, string alias, DataType basic, DataType parent,
     bool editable, double size, bool autoSize, bool nullable)
     : base(id, name, alias, basic, parent, editable, nullable)
 {
     this.size = size;
     this.autoSize = autoSize;
 }
Example #3
0
 public DateTimeDataType(int id, string name, string alias, DataType basic, DataType parent, bool editable,
     DateTimeKind part, DateTime minValue, DateTime maxValue, bool nullable)
     : base(id, name, alias, basic, parent, editable, nullable)
 {
     this.part = part;
     this.minValue = minValue;
     this.maxValue = maxValue;
 }
Example #4
0
 /// <summary>
 /// �����������������У�����ߵ��������͡�
 /// </summary>
 /// <param name="typeLeft">��һ����������</param>
 /// <param name="typeRight">�ڶ�����������</param>
 /// <returns>������������</returns>
 public static DataType GetDestDataType(DataType typeLeft, DataType typeRight)
 {
     //ȡ����������ID��
     int leftDataTypeId = typeLeft.BasicId;
     int rightDataTypeId = typeRight.BasicId;
     //������ͬ��
     if (leftDataTypeId == rightDataTypeId)
     {
         return typeLeft;
     }
     //���Ͳ�ͬ��
     if (leftDataTypeId <= DataTypeRegistry.ID_UINT64 && rightDataTypeId <= DataTypeRegistry.ID_UINT64)
     {
         int r1 = leftDataTypeId % 2;
         int r2 = rightDataTypeId % 2;
         if (r1 == r2)//������ͬ
         {
             if (r1 == 1)
             {
                 return GetDestDataType(typeLeft, typeRight, DataTypeRange1);
             }
             else
             {
                 return GetDestDataType(typeLeft, typeRight, DataTypeRange2);
             }
         }
         else//���Ų�ͬ
         {
             //�޷���ת��Ϊ�з���
             int indexLeft, indexRight;
             if (r1 == 0)
             {
                 indexLeft = IndexOf(leftDataTypeId, DataTypeRange2) + 1;
                 indexRight = IndexOf(rightDataTypeId, DataTypeRange1);
             }
             else
             {
                 indexLeft = IndexOf(leftDataTypeId, DataTypeRange1);
                 indexRight = IndexOf(rightDataTypeId, DataTypeRange2) + 1;
             }
             return GetDestDataType(indexLeft, typeLeft, indexRight, typeRight, DataTypeRange1);
         }
     }
     else
     {
         //��һ�����޷��š�
         if (((leftDataTypeId <= DataTypeRegistry.ID_UINT64) && (leftDataTypeId % 2 == 0))
             || ((rightDataTypeId <= DataTypeRegistry.ID_UINT64) && (rightDataTypeId % 2 == 0)))
         {
             return GetDestDataType(typeLeft, typeRight, DataTypeRange1);
         }
         //�����з��ŵġ�
         return GetDestDataType(typeLeft, typeRight, DataTypeRange2);
     }
 }
Example #5
0
 public DataType(int id, string name, string alias, DataType basic, DataType parent, bool editable, bool nullable)
 {
     this.id = id;
     this.name = name;
     this.alias = alias;
     if (parent == null)
     {
         basic = null;
     }
     this.basic = basic;
     this.parent = parent;
     this.editable = editable;
 }
Example #6
0
 private static DataType GetDestDataType(int indexLeft, DataType typeLeft, int indexRight, DataType typeRight, DataType[] list)
 {
     int dataTypeIdx = Math.Max(indexLeft, indexRight);
     if (dataTypeIdx < 0)
     {
         throw new FireSpiderException("�������ʽ���ߵĵ����Ͳ�һ�£����: " + typeLeft + ", �ұߣ�" + typeRight);
     }
     return list[dataTypeIdx];
 }
Example #7
0
 private static DataType GetDestDataType(DataType typeLeft, DataType typeRight, DataType[] list)
 {
     return GetDestDataType(IndexOf(typeLeft.BasicId, list), typeLeft, IndexOf(typeRight.BasicId, list), typeRight, list);
 }
Example #8
0
 /// <summary>
 /// ȡ������������
 /// </summary>
 /// <param name="value"></param>
 /// <param name="list"></param>
 /// <returns></returns>
 public static int IndexOf(DataType dataType, DataType[] list)
 {
     return IndexOf(dataType.BasicId, list);
 }
Example #9
0
 protected abstract DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent);
Example #10
0
 public object ToObject(DataType dataType, object value, ConvertSetting convertSetting)
 {
     switch (dataType.BasicId)
     {
         case DataTypeRegistry.ID_BYTE:
             return ToByte(value, convertSetting);
         case DataTypeRegistry.ID_SBYTE:
             return ToSByte(value, convertSetting);
         case DataTypeRegistry.ID_INT16:
             return ToInt16(value, convertSetting);
         case DataTypeRegistry.ID_UINT16:
             return ToUInt16(value, convertSetting);
         case DataTypeRegistry.ID_INT32:
             return ToInt32(value, convertSetting);
         case DataTypeRegistry.ID_UINT32:
             return ToUInt32(value, convertSetting);
         case DataTypeRegistry.ID_INT64:
             return ToInt64(value, convertSetting);
         case DataTypeRegistry.ID_UINT64:
             return ToUInt64(value, convertSetting);
         case DataTypeRegistry.ID_SINGLE:
             return ToSingle(value, convertSetting);
         case DataTypeRegistry.ID_DOUBLE:
             return ToDouble(value, convertSetting);
         case DataTypeRegistry.ID_DECIMAL:
             return ToDecimal(value, convertSetting);
         case DataTypeRegistry.ID_BOOLEAN:
             return ToBoolean(value, convertSetting);
         case DataTypeRegistry.ID_DATETIME:
             return ToDateTime(value, convertSetting);
         case DataTypeRegistry.ID_STRING:
             return ToString(value, convertSetting);
         case DataTypeRegistry.ID_GUID:
             return ToGuid(value, convertSetting);
         case DataTypeRegistry.ID_BINARY:
             return ToBinary(value, convertSetting);
         case DataTypeRegistry.ID_CHAR:
             return ToChar(value, convertSetting);
         default:
             return ToObject(value);
     }
 }
Example #11
0
 protected override DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent)
 {
     return new DateTimeDataType(id, name, alias, basic, parent, true, part, ((DateTimeDataType)parent).MinValue, ((DateTimeDataType)parent).MaxValue, parent.Nullable);
 }
Example #12
0
 protected override DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent)
 {
     return new DecimalDataType(id, name, alias, basic, parent, true, ((DecimalDataType)parent).Precision, ((DecimalDataType)parent).Scale, parent.Nullable);
 }
Example #13
0
 public static int GetDataTypeIndex(DataType dataType)
 {
     return _nameTypes.IndexByKey(dataType.Name);
 }
 public SingleDataTypeValueWriter(DataType dataType)
 {
     this.dataType = dataType;
 }
 private void CheckDataType(DataType dataType)
 {
     if (dataType == null)
     {
         throw new Exception("�޷�����������ͣ�");
     }
 }
 protected abstract void GetDataTypeAndValue(string nodeName, ref DataType dataType, ref object value);
 protected abstract void GetDataTypeAndValue(int nodeIndex, ref DataType dataType, ref object value);
Example #18
0
 public DataType NewInstance(int id, string name, string alias, DataType parent, int size, bool autoSize)
 {
     StringDataType dataType = (StringDataType)NewInstance(id, name, alias, parent);
     dataType.Size = size;
     dataType.AutoSize = autoSize;
     return dataType;
 }
 public SingleDataTypeValueReader(DataType dataType)
 {
     this.dataType = dataType;
 }
Example #20
0
 /// <summary>
 /// ȡ������������
 /// </summary>
 /// <param name="value"></param>
 /// <param name="list"></param>
 /// <returns></returns>
 private static int IndexOf(int dataTypeId, DataType[] list)
 {
     int offset = 0;
     for (int end = list.Length; offset < end; offset++)
     {
         if (((DataType)list[offset]).BasicId == dataTypeId)
         {
             return offset;
         }
     }
     return -1;
 }
Example #21
0
 public Int32DataType(int id, string name, string alias, DataType basic, DataType parent, bool editable, bool nullable)
     : base(id, name, alias, basic, parent, editable, nullable)
 {
 }
Example #22
0
 public DataType NewInstance(int id, string name, string alias, DataType parent, int precision, int scale)
 {
     DecimalDataType dataType = (DecimalDataType)NewInstance(id, name, alias, parent);
     dataType.Precision = precision;
     dataType.Scale = scale;
     return dataType;
 }
Example #23
0
 protected override DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent)
 {
     return new SByteDataType(id, name, alias, basic, parent, true, parent.Nullable);
 }
Example #24
0
 public object FromObject(DataType dataType, object value, ConvertSetting convertSetting)
 {
     switch (dataType.BasicId)
     {
         case DataTypeRegistry.ID_BYTE:
             return FromByte((byte)value, convertSetting);
         case DataTypeRegistry.ID_SBYTE:
             return FromSByte((sbyte)value, convertSetting);
         case DataTypeRegistry.ID_INT16:
             return FromInt16((short)value, convertSetting);
         case DataTypeRegistry.ID_UINT16:
             return FromUInt16((ushort)value, convertSetting);
         case DataTypeRegistry.ID_INT32:
             return FromInt32((int)value, convertSetting);
         case DataTypeRegistry.ID_UINT32:
             return FromUInt32((uint)value, convertSetting);
         case DataTypeRegistry.ID_INT64:
             return FromInt64((long)value, convertSetting);
         case DataTypeRegistry.ID_UINT64:
             return FromUInt64((ulong)value, convertSetting);
         case DataTypeRegistry.ID_SINGLE:
             return FromSingle((float)value, convertSetting);
         case DataTypeRegistry.ID_DOUBLE:
             return FromDouble((double)value, convertSetting);
         case DataTypeRegistry.ID_DECIMAL:
             return FromDecimal((decimal)value, convertSetting);
         case DataTypeRegistry.ID_CHAR:
             return FromChar((char)value, convertSetting);
         case DataTypeRegistry.ID_BOOLEAN:
             return FromBoolean((bool)value, convertSetting);
         case DataTypeRegistry.ID_DATETIME:
             return FromDateTime((DateTime)value, convertSetting);
         case DataTypeRegistry.ID_STRING:
             return FromString((string)value, convertSetting);
         case DataTypeRegistry.ID_GUID:
             return FromGuid((Guid)value, convertSetting);
         case DataTypeRegistry.ID_BINARY:
             return FromBinary((Byte[])value, 0, convertSetting);
         default:
             return FromObject(value, convertSetting);
     }
 }
Example #25
0
 /// <summary>
 /// 注册数据类型
 /// </summary>
 /// <param name="dataType"></param>
 private static void Register(DataType dataType)
 {
     lock (_nameTypes)
     {
         _nameTypes.Add(dataType.Name, dataType);
     }
     lock (_aliasTypes)
     {
         _aliasTypes.Add(dataType.Alias, dataType);
     }
     lock (_valueTypes)
     {
         _valueTypes.Add(dataType.PrimitiveType.Name, dataType);
     }
 }
Example #26
0
 /// <summary>
 /// 新类型实例。
 /// </summary>
 /// <param name="id">类型ID</param>
 /// <param name="name">类型名称</param>
 /// <param name="parent">父类型</param>
 /// <returns></returns>
 public DataType NewInstance(int id, string name, string alias, DataType parent)
 {
     if (basic == null) { basic = this; }
     DataType dataType = NewInstance(id, name, alias, basic, parent);
     dataType.isInstance = true;
     return dataType;
 }
Example #27
0
 protected override DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent)
 {
     if (basic == null) { basic = this; }
     return new Int32DataType(id, name, alias, basic, parent, true, parent.Nullable);
 }
Example #28
0
 public object ToObject(DataType dataType, object value)
 {
     return ToObject(dataType, value, ConvertSetting.Default);
 }