Ejemplo n.º 1
0
 public static UpdateFieldCollection Get(ObjectTypeId type)
 {
     if (UpdateFieldMgr.Collections[0] == null)
     {
         UpdateFieldMgr.Init();
     }
     return(UpdateFieldMgr.Collections[(int)type]);
 }
Ejemplo n.º 2
0
        public static void Init()
        {
            UpdateFieldMgr.InitInheritance();
            UpdateFieldMgr.FixFields();
            for (ObjectTypeId id = ObjectTypeId.Object; id < ObjectTypeId.Count; ++id)
            {
                UpdateField[] fields           = (UpdateField[])UpdateFields.AllFields[(int)id].Clone();
                int           offset           = int.MaxValue;
                bool          hasPrivateFields = false;
                UpdateField   updateField1     = (UpdateField)null;
                for (int index = 0; index < fields.Length; ++index)
                {
                    UpdateField updateField2 = fields[index];
                    if (updateField2 != null)
                    {
                        if (offset == int.MaxValue)
                        {
                            offset = (int)updateField2.Offset;
                        }
                        updateField1     = updateField2;
                        hasPrivateFields = hasPrivateFields ||
                                           (updateField2.Flags & UpdateFieldFlags.Private) != UpdateFieldFlags.None;
                    }
                    else if (updateField1 != null)
                    {
                        fields[index] = updateField1;
                    }
                }

                ObjectTypeId          inheritedTypeId = UpdateFieldMgr.InheritedTypeIds[(int)id];
                UpdateFieldCollection baseCollection;
                if (inheritedTypeId != ObjectTypeId.None)
                {
                    baseCollection = UpdateFieldMgr.Collections[(int)inheritedTypeId];
                    if (baseCollection.Fields.Length >= fields.Length)
                    {
                        throw new Exception("BaseCollection of UpdateFields equal or bigger than inherited collection");
                    }
                    for (int index = 0; index < baseCollection.Fields.Length; ++index)
                    {
                        UpdateField field = baseCollection.Fields[index];
                        fields[index] = field;
                    }
                }
                else
                {
                    baseCollection = (UpdateFieldCollection)null;
                }

                UpdateFieldMgr.Collections[(int)id] =
                    new UpdateFieldCollection(id, fields, baseCollection, offset, hasPrivateFields);
            }
        }