private void CreatePropValue(ITable propTable, int resID, int propID, object value) { IRecord rec = propTable.NewRecord(); rec.SetValue(0, IntInternalizer.Intern(resID)); rec.SetValue(1, IntInternalizer.Intern(propID)); rec.SetValue(2, value); rec.Commit(); }
/** * Adds a record for the specified prop type to the DB. */ internal int RegisterPropTypeInternal(string name, PropDataType propType, PropTypeFlags flags, bool forceType, out bool newPropType) { _storage.CheckOwnerThread(); IRecord rec = _propTypeTable.GetRecordByEqual(1, name); if (rec != null) { if (!_propTypeNameCache.ContainsKey(name)) { throw new BadIndexesException("Property type " + name + " found in PropTypes table but missing in name cache"); } bool recordChanged = false; if (rec.GetIntValue(2) != (int)propType) { if (forceType) { rec.SetValue(2, IntInternalizer.Intern((int)propType)); ((PropTypeItem)this[name]).SetDataType(propType); recordChanged = true; } else { throw new StorageException("Inconsistent registration for property type " + name + ": old type " + (PropDataType)rec.GetIntValue(2) + ", new type " + propType); } } int propId = rec.GetIntValue(0); PropTypeFlags newFlags = flags | this [propId].Flags; if (rec.GetIntValue(3) != (int)newFlags) { rec.SetValue(3, (int)newFlags); recordChanged = true; } if (recordChanged) { rec.Commit(); } newPropType = false; PropTypeItem propTypeItem = (PropTypeItem)_propTypeCache [propId]; propTypeItem.SetFlags(newFlags); return(propId); } if ((flags & (PropTypeFlags.DirectedLink | PropTypeFlags.CountUnread)) != 0 && propType != PropDataType.Link) { throw new StorageException("DirectedLink and CountUnread flags can be used only on Link properties"); } int ID; lock ( _propTypeTable ) { IRecord propertyType = _propTypeTable.NewRecord(); propertyType.SetValue(1, name); propertyType.SetValue(2, IntInternalizer.Intern((int)propType)); propertyType.SetValue(3, (int)flags); _storage.SafeCommitRecord(propertyType, "PropTypeCollection.RegisterPropTypeInternal"); ID = propertyType.GetID(); if (ID > 65536) { MyPalStorage.Storage.OnIndexCorruptionDetected("Invalid next ID in property type table"); } } AddPropTypeToCache(ID, name, propType, flags); newPropType = true; return(ID); }
public void SetIntKey(int key) { _Key = (IComparable)IntInternalizer.Intern(key); }
public override void LoadValue(SafeBinaryReader reader) { _fields[_fieldIndex] = IntInternalizer.Intern(reader.ReadInt32()); }