Esempio n. 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;
                }
            }
        }
Esempio n. 2
0
 static IUpdateValue GetUpdateValue(Type valueType, MemberValue memberValue, int field)
 {
     if (valueType == typeof(ulong))
     {
         if ((field % 2) == 0)
         {
             return(new UInt64UpdateValue(memberValue, field));
         }
         else
         {
             return(new UInt64UpdateValueUneven(memberValue, field));
         }
     }
     else if (valueType == typeof(long))
     {
         if ((field % 2) == 0)
         {
             return(new Int64UpdateValue(memberValue, field));
         }
         else
         {
             return(new Int64UpdateValueUneven(memberValue, field));
         }
     }
     else if (valueType == typeof(uint))
     {
         return(new UInt32UpdateValue(memberValue, field));
     }
     else if (valueType == typeof(int))
     {
         return(new Int32UpdateValue(memberValue, field));
     }
     else if (valueType == typeof(float))
     {
         return(new FloatUpdateValue(memberValue, field));
     }
     throw new ObjectUpdateManagerException("Invalid UpdateValue type " + valueType.ToString() + " on " + memberValue.GetName());
 }
Esempio n. 3
0
        static void GetBytesUpdateValue(Hashtable tbl, MemberValue value, int field)
        {
            UpdateValueAttribute attrib = (UpdateValueAttribute)value.Attribute;

            if (attrib.BytesIndex < 0 || attrib.BytesIndex > 3)
            {
                throw new ObjectUpdateManagerException("BytesIndex out of range on " + value.GetName() + " BytesIndex = " + attrib.BytesIndex);
            }
            BytesUpdateValue v;

            if (tbl.Contains(field))
            {
                IUpdateValue tmp = (IUpdateValue)tbl[field];
                if (!(tmp is BytesUpdateValue))
                {
                    throw new ObjectUpdateManagerException("Field " + field + " was a " + tmp.GetType() + " not a BytesUpdateValue (" + value.GetName() + ")");
                }
                v = (BytesUpdateValue)tmp;
            }
            else
            {
                v          = new BytesUpdateValue(field);
                tbl[field] = v;
            }
            v.SetMemberValue(value, attrib.BytesIndex);
        }
Esempio n. 4
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);
        }