Пример #1
0
        internal void CreateOrUpdatePropTypeResource(string name, PropDataType dataType, PropTypeFlags flags, IPlugin ownerPlugin, int ID, bool newPropType)
        {
            if (newPropType)
            {
                IResource res;
                try
                {
                    res = CreatePropTypeResource(ID, name, dataType, flags);
                }
                catch (ResourceRestrictionException ex)   // OM-9471
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("ResourceRestrictionException when creating PropType resource: " +
                                                                   ex.Message);
                    return;
                }
                _storage.SetOwnerPlugin(res, ownerPlugin);
            }
            else
            {
                IResource res = _storage.FindUniqueResource("PropType", "Name", name);

                if (res != null)
                {
                    res.SetProp("Flags", (int)this [name].Flags);      // ensure OR'ed flags are applied correctly
                    _storage.SetOwnerPlugin(res, ownerPlugin);
                }
                else
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("Could not find PropType resource for property type " + name);
                }
            }
        }
Пример #2
0
        internal void CreateOrUpdateResourceTypeResource(string name, string displayName,
                                                         string resourceDisplayNameTemplate, ResourceTypeFlags flags, IPlugin ownerPlugin,
                                                         int ID, bool newType)
        {
            ResourceTypeFlags oldFlags = ResourceTypeFlags.Normal;

            IResource res;

            if (newType)
            {
                try
                {
                    res = CreateResourceTypeResource(ID, name, resourceDisplayNameTemplate);
                }
                catch (ResourceRestrictionException ex)
                {
                    MyPalStorage.Storage.OnIndexCorruptionDetected("ResourceRestrictionException when creating PropType resource: " +
                                                                   ex.Message);
                    return;
                }
            }
            else
            {
                res      = _storage.FindUniqueResource("ResourceType", _storage.Props.Name, name);
                oldFlags = this [name].Flags;
            }

            if (res == null)
            {
                MyPalStorage.Storage.OnIndexCorruptionDetected("Could not find ResourceType resource with name " + name);
            }
            else
            {
                SetResourceTypeFlags(res, flags);
                res.SetProp(_storage.Props.PropDisplayName, displayName);

                _storage.SetOwnerPlugin(res, ownerPlugin);
            }

            UpdateResourceTypeCache(ID, resourceDisplayNameTemplate, flags | oldFlags);

            if (newType)
            {
                _storage.CacheResourceTypePredicate((ResourceTypeItem)_resourceTypeCache [ID]);
            }
        }