Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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];
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 9
0
 protected abstract DataType NewInstance(int id, string name, string alias, DataType basic, DataType parent);
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 13
0
 public static int GetDataTypeIndex(DataType dataType)
 {
     return _nameTypes.IndexByKey(dataType.Name);
 }
 public SingleDataTypeValueWriter(DataType dataType)
 {
     this.dataType = dataType;
 }
Exemplo n.º 15
0
 private void CheckDataType(DataType dataType)
 {
     if (dataType == null)
     {
         throw new Exception("�޷�����������ͣ�");
     }
 }
Exemplo n.º 16
0
 protected abstract void GetDataTypeAndValue(string nodeName, ref DataType dataType, ref object value);
Exemplo n.º 17
0
 protected abstract void GetDataTypeAndValue(int nodeIndex, ref DataType dataType, ref object value);
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 28
0
 public object ToObject(DataType dataType, object value)
 {
     return ToObject(dataType, value, ConvertSetting.Default);
 }