public void Append(IPersistent obj) { lock (this) { Key key; object val; switch (type) { case ClassDescriptor.FieldType.tpInt: key = new Key((int)autoincCount); val = (int)autoincCount; break; case ClassDescriptor.FieldType.tpLong: key = new Key(autoincCount); val = autoincCount; break; default: throw new StorageError(StorageError.ErrorCode.UNSUPPORTED_INDEX_TYPE, mbrType); } if (mbr is FieldInfo) { ((FieldInfo)mbr).SetValue(obj, val); } else { ((PropertyInfo)mbr).SetValue(obj, val, null); } autoincCount += 1; obj.Modify(); base.insert(key, obj, false); } }
public virtual int MakePersistent(IPersistent obj) { lock (this) { if (!opened) throw new StorageError(StorageError.STORAGE_NOT_OPENED); if (obj == null) return 0; int oid = obj.Oid; if (oid != 0) return oid; lock (objectCache) { oid = AllocateId(); obj.AssignOid(this, oid, false); SetPos(oid, 0); objectCache.Put(oid, obj); obj.Modify(); return oid; } } }
public virtual void Append(IPersistent obj) { lock (this) { Key key; try { switch (type) { case ClassDescriptor.tpInt: key = new Key((int) autoincCount); fld.SetValue(obj, (int) autoincCount); break; case ClassDescriptor.tpLong: key = new Key(autoincCount); fld.SetValue(obj, autoincCount); break; default: throw new StorageError(StorageError.UNSUPPORTED_INDEX_TYPE, fld.FieldType); } } catch (System.Exception x) { throw new StorageError(StorageError.ACCESS_VIOLATION, x); } autoincCount += 1; obj.Modify(); base.Insert(key, obj, false); } }