Пример #1
0
        static void GetShortsUpdateValue(Hashtable tbl, MemberValue value, int field)
        {
            UpdateValueAttribute attrib = (UpdateValueAttribute)value.Attribute;

            if (attrib.ShortsIndex < 0 || attrib.ShortsIndex > 1)
            {
                throw new ObjectUpdateManagerException("ShortsIndex out of range on " + value.GetName() + " ShortsIndex = " + attrib.ShortsIndex);
            }
            if (tbl.Contains(field))
            {
                object tmp   = tbl[field];
                Type   cType = tmp.GetType();
                if (cType != typeof(ShortUU_UpdateValue) && cType != typeof(ShortSS_UpdateValue))
                {
                    throw new ObjectUpdateManagerException("Failed to combine short values on field " + field + ", type " + tmp.GetType() + " was already in hashtable (" + value.GetName() + ")");
                }
                IShortsCombine c = (IShortsCombine)tmp;
                tbl[field] = c.ShortsCombine(value, attrib.ShortsIndex, value.GetValueType());
            }
            else
            {
                if (value.GetValueType() == typeof(short))
                {
                    ShortSS_UpdateValue uv = new ShortSS_UpdateValue(field);
                    uv.SetMemberValue(value, attrib.ShortsIndex);
                    tbl[field] = uv;
                }
                else
                {
                    ShortUU_UpdateValue uv = new ShortUU_UpdateValue(field);
                    uv.SetMemberValue(value, attrib.ShortsIndex);
                    tbl[field] = uv;
                }
            }
        }
Пример #2
0
        static void AddUpdateValue(Hashtable tbl, MemberValue value, int field)
        {
            Type valueType = value.GetValueType();

            if (valueType == typeof(short) || valueType == typeof(ushort))
            {
                GetShortsUpdateValue(tbl, value, field);
            }
            else if (valueType == typeof(byte))
            {
                GetBytesUpdateValue(tbl, value, field);
            }
            else
            {
                if (tbl.Contains(field) ||
                    ((valueType == typeof(ulong) || valueType == typeof(long)) && tbl.Contains(field + 1)))
                {
                    throw new ObjectUpdateManagerException("There is already an updateval handler assigned to field " + field + " (" + value.GetName() + ")");
                }
                tbl[field] = GetUpdateValue(valueType, value, field);
            }
            //Console.WriteLine(value.GetName() + " " + field);
        }