コード例 #1
0
        public bool UpdateObject(object keyValue, string[] newSerializedOtherFields)
        {
            KClass target = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));

            target.SerializedOtherData = new DClass(newSerializedOtherFields);
            return(m_tree.UpdateData(target));
        }
コード例 #2
0
ファイル: ObjectTree.cs プロジェクト: luanzhu/OOD.NET
		public bool InsertObject(object keyValue, string[] serializedOtherFields)
		{
			KClass key = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));
			key.SerializedOtherData = new DClass(serializedOtherFields);

			return m_tree.Insert(key);
		}
コード例 #3
0
        public bool InsertObject(object keyValue, string[] serializedOtherFields)
        {
            KClass key = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));

            key.SerializedOtherData = new DClass(serializedOtherFields);

            return(m_tree.Insert(key));
        }
コード例 #4
0
ファイル: ObjectTree.cs プロジェクト: luanzhu/OOD.NET
		public ObjectInfo SearchObject(object keyValue)
		{
			KClass key = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));
			KClass obj = (KClass) m_tree.Search(key);
			if (obj != null)
			{
				Debug.Assert(obj.SerializedOtherData != null);
				ObjectInfo result = new ObjectInfo(key.DataType, key.KValue, obj.SerializedOtherData.SerializedValues);

				return result;
			}
			else
				return null;
		}
コード例 #5
0
        public ObjectInfo SearchObject(object keyValue)
        {
            KClass key = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));
            KClass obj = (KClass)m_tree.Search(key);

            if (obj != null)
            {
                Debug.Assert(obj.SerializedOtherData != null);
                ObjectInfo result = new ObjectInfo(key.DataType, key.KValue, obj.SerializedOtherData.SerializedValues);

                return(result);
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
ファイル: KClass.cs プロジェクト: luanzhu/OOD.NET
		public IKey Deserialize(byte[] bytes, int offset, int count)
		{
			KClass result = new KClass();
			int pos = offset;

			result.m_type = (Types.InternalType)bytes[pos++];

			int len = OOD.Utility.Bytes.Unpack2(bytes, pos);
			pos += 2;
			string strValue = System.Text.ASCIIEncoding.ASCII.GetString(bytes, pos, len);
			pos +=len;

			switch (result.m_type)
			{
				case Types.InternalType.t_Byte:
					result.m_value = Convert.ToByte(strValue);
					break;
				case Types.InternalType.t_SByte:
					result.m_value = Convert.ToSByte(strValue);
					break;
				case Types.InternalType.t_Short:
					result.m_value = Convert.ToInt16(strValue);
					break;
				case Types.InternalType.t_UShort:
					result.m_value = Convert.ToUInt16(strValue);
					break;
				case Types.InternalType.t_Char:
					result.m_value = Convert.ToChar(strValue);
					break;
				case Types.InternalType.t_Int:
					result.m_value = Convert.ToInt32(strValue);
					break;
				case Types.InternalType.t_UInt:
					result.m_value = Convert.ToUInt32(strValue);
					break;
				case Types.InternalType.t_Long:
					result.m_value = Convert.ToInt64(strValue);
					break;
				case Types.InternalType.t_ULong:
					result.m_value = Convert.ToUInt64(strValue);
					break;
				case Types.InternalType.t_Float:
					result.m_value = Convert.ToSingle(strValue);
					break;
				case Types.InternalType.t_Double:
					result.m_value = Convert.ToDouble(strValue);
					break;
				case Types.InternalType.t_String:
					result.m_value = strValue;
					break;
			}

			if (count > pos - offset)
			{
				//IDATA is there too
				m_object_data = new DClass();
				result.m_object_data = (DClass)m_object_data.Deserialize(bytes, pos, count - (pos - offset));
			}


			return result;
		}
コード例 #7
0
ファイル: ObjectTree.cs プロジェクト: luanzhu/OOD.NET
		public bool DeleteObject(object keyValue)
		{
			KClass target = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));
			return m_tree.Delete(target);
		}
コード例 #8
0
ファイル: ObjectTree.cs プロジェクト: luanzhu/OOD.NET
		public bool UpdateObject(object keyValue, string[] newSerializedOtherFields)
		{
			KClass target = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));
			target.SerializedOtherData = new DClass(newSerializedOtherFields);
			return m_tree.UpdateData(target);
		}
コード例 #9
0
        public IKey Deserialize(byte[] bytes, int offset, int count)
        {
            KClass result = new KClass();
            int    pos    = offset;

            result.m_type = (Types.InternalType)bytes[pos++];

            int len = OOD.Utility.Bytes.Unpack2(bytes, pos);

            pos += 2;
            string strValue = System.Text.ASCIIEncoding.ASCII.GetString(bytes, pos, len);

            pos += len;

            switch (result.m_type)
            {
            case Types.InternalType.t_Byte:
                result.m_value = Convert.ToByte(strValue);
                break;

            case Types.InternalType.t_SByte:
                result.m_value = Convert.ToSByte(strValue);
                break;

            case Types.InternalType.t_Short:
                result.m_value = Convert.ToInt16(strValue);
                break;

            case Types.InternalType.t_UShort:
                result.m_value = Convert.ToUInt16(strValue);
                break;

            case Types.InternalType.t_Char:
                result.m_value = Convert.ToChar(strValue);
                break;

            case Types.InternalType.t_Int:
                result.m_value = Convert.ToInt32(strValue);
                break;

            case Types.InternalType.t_UInt:
                result.m_value = Convert.ToUInt32(strValue);
                break;

            case Types.InternalType.t_Long:
                result.m_value = Convert.ToInt64(strValue);
                break;

            case Types.InternalType.t_ULong:
                result.m_value = Convert.ToUInt64(strValue);
                break;

            case Types.InternalType.t_Float:
                result.m_value = Convert.ToSingle(strValue);
                break;

            case Types.InternalType.t_Double:
                result.m_value = Convert.ToDouble(strValue);
                break;

            case Types.InternalType.t_String:
                result.m_value = strValue;
                break;
            }

            if (count > pos - offset)
            {
                //IDATA is there too
                m_object_data        = new DClass();
                result.m_object_data = (DClass)m_object_data.Deserialize(bytes, pos, count - (pos - offset));
            }


            return(result);
        }
コード例 #10
0
        public int CompareTo(IKey B)
        {
            KClass KB = (KClass)B;

            switch (this.m_type)
            {
            case Types.InternalType.t_Byte:
                return((byte)this.m_value - (byte)KB.m_value);

            case Types.InternalType.t_SByte:
                return((sbyte)this.m_value - (sbyte)KB.m_value);

            case Types.InternalType.t_Short:
                return((short)this.m_value - (short)KB.m_value);

            case Types.InternalType.t_UShort:
                return((ushort)this.m_value - (ushort)KB.m_value);

            case Types.InternalType.t_Char:
                return((char)this.m_value - (char)KB.m_value);

            case Types.InternalType.t_Int:
                return((int)this.m_value - (int)KB.m_value);

            case Types.InternalType.t_UInt:
                return((int)((uint)this.m_value - (uint)KB.m_value));

            case Types.InternalType.t_Long:
                return((int)((long)this.m_value - (long)KB.m_value));

            case Types.InternalType.t_ULong:
                return((int)((ulong)this.m_value - (ulong)KB.m_value));

            case Types.InternalType.t_Float:
                float tmp = (float)this.m_value - (float)KB.m_value;
                if (tmp > 0)
                {
                    return(1);
                }
                else if (tmp < 0)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }

            case Types.InternalType.t_Double:
                double d_tmp = (double)this.m_value - (double)KB.m_value;
                if (d_tmp > 0)
                {
                    return(1);
                }
                else if (d_tmp < 0)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }

            case Types.InternalType.t_String:
                return(string.Compare((string)m_value, (string)KB.m_value, false, System.Globalization.CultureInfo.InvariantCulture));
            }

            throw new OOD.Exception.NotImplemented(
                      this,
                      "Unsupported type for primary key detected.");
        }
コード例 #11
0
        public bool DeleteObject(object keyValue)
        {
            KClass target = new KClass(keyValue, OOD.Types.GetInternalType(keyValue.GetType()));

            return(m_tree.Delete(target));
        }