internal void UpdateResourceType(string name, string displayNameTemplate, ResourceTypeFlags flags, string propDisplayName) { ICountedResultSet rs = _resourceTypeTable.CreateModifiableResultSet(1, name); try { if (rs.Count > 0) { IRecord rec = rs [0]; if (rec.GetStringValue(2) != displayNameTemplate) { rec.SetValue(2, displayNameTemplate); _storage.SafeCommitRecord(rec, "ResourceTypeCollection.UpdateResourceType"); } int resID = rec.GetIntValue(0); UpdateResourceTypeCache(resID, displayNameTemplate, flags); ResourceTypeItem item = (ResourceTypeItem)this [resID]; item.SetDisplayName(propDisplayName); } } finally { rs.Dispose(); } }
public void Delete(string name) { ResourceTypeItem item = (ResourceTypeItem)this [name]; IResourceList resList = _storage.GetAllResources(name); resList.DeleteAll(); _resourceTypeCache [item.Id] = null; _resourceTypeNameCache.Remove(name); ICountedResultSet rs = _resourceTypeTable.CreateModifiableResultSet(0, item.Id); try { _storage.SafeDeleteRecord(rs [0], "ResourceTypes.Delete"); } finally { rs.Dispose(); } IResource resourceTypeRes = _storage.FindUniqueResource("ResourceType", "Name", name); Debug.Assert(resourceTypeRes != null); resourceTypeRes.Delete(); }
/// <summary> /// Adds a new ResourceTypeItem to the resource type cache. /// </summary> private void AddResourceTypeToCache(int ID, string name, string displayNameTemplate, ResourceTypeFlags flags) { if (ID < 0 || ID > 65536) { throw new BadIndexesException("Invalid resource type ID " + ID); } lock ( _resourceTypeCache ) { ResourceTypeItem item = new ResourceTypeItem(ID, name, displayNameTemplate, flags); while (_resourceTypeCache.Count < ID) { _resourceTypeCache.Add(null); } if (_resourceTypeCache.Count == ID) { _resourceTypeCache.Add(item); } else { _resourceTypeCache [ID] = item; } _resourceTypeNameCache [name] = item; } }
internal void UpdateResourceTypeCache(int resTypeID, string displayNameMask, ResourceTypeFlags flags) { ResourceTypeItem item = (ResourceTypeItem)_resourceTypeCache [resTypeID]; Debug.Assert(item != null); Debug.Assert(item.Id == resTypeID); item.SetDisplayNameTemplate(displayNameMask, true); item.SetFlags(flags); }
public IResourceType this [string name] { get { ResourceTypeItem item = (ResourceTypeItem)_resourceTypeNameCache [name]; if (item == null) { throw new StorageException("Invalid resource type name " + name); } return(item); } }
internal IResourceType GetItemSafe(int id) { if (id < 0 || id >= _resourceTypeCache.Count) { MyPalStorage.Storage.OnIndexCorruptionDetected("Invalid resource type ID " + id + ": cache count " + _resourceTypeCache.Count); return(null); } ResourceTypeItem item = (ResourceTypeItem)_resourceTypeCache [id]; if (item == null) { MyPalStorage.Storage.OnIndexCorruptionDetected("Invalid resource type ID " + id + ": cache count " + _resourceTypeCache.Count); } return(item); }
public IResourceType this [int ID] { get { if (ID < 0 || ID >= _resourceTypeCache.Count) { throw new StorageException("Invalid resource type ID " + ID + ": cache count " + _resourceTypeCache.Count); } ResourceTypeItem item = (ResourceTypeItem)_resourceTypeCache [ID]; if (item == null) { throw new StorageException("Invalid resource type ID " + ID + ": null element in cache"); } return(item); } }