本文整理汇总了C#中NeoDatis.GetClassInfo方法的典型用法代码示例。如果您正苦于以下问题:C# NeoDatis.GetClassInfo方法的具体用法?C# NeoDatis.GetClassInfo怎么用?C# NeoDatis.GetClassInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeoDatis
的用法示例。
在下文中一共展示了NeoDatis.GetClassInfo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteNonNativeObjectInfo
public virtual NeoDatis.Odb.OID WriteNonNativeObjectInfo(NeoDatis.Odb.OID existingOid
, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo objectInfo, long position
, bool writeDataInTransaction, bool isNewObject)
{
NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
bool hasObject = objectInfo.GetObject() != null;
// Insert triggers for CS Mode, local mode insert triggers are called in the DefaultInstrumentationCallbackForStore class
if (isNewObject && !isLocalMode)
{
triggerManager.ManageInsertTriggerBefore(objectInfo.GetClassInfo().GetFullClassName
(), objectInfo);
}
// Checks if object is null,for null objects,there is nothing to do
if (objectInfo.IsNull())
{
return NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant.NullObjectId;
}
NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = lsession.GetMetaModel(
);
// first checks if the class of this object already exist in the
// metamodel
if (!metaModel.ExistClass(objectInfo.GetClassInfo().GetFullClassName()))
{
AddClass(objectInfo.GetClassInfo(), true);
}
// if position is -1, gets the position where to write the object
if (position == -1)
{
// Write at the end of the file
position = fsi.GetAvailablePosition();
// Updates the meta object position
objectInfo.SetPosition(position);
}
// Gets the object id
NeoDatis.Odb.OID oid = existingOid;
if (oid == null)
{
// If, to get the next id, a new id block must be created, then
// there is an extra work
// to update the current object position
if (idManager.MustShift())
{
oid = idManager.GetNextObjectId(position);
// The id manager wrote in the file so the position for the
// object must be re-computed
position = fsi.GetAvailablePosition();
// The oid must be associated to this new position - id
// operations are always out of transaction
// in this case, the update is done out of the transaction as a
// rollback won t need to
// undo this. We are just creating the id
// => third parameter(write in transaction) = false
idManager.UpdateObjectPositionForOid(oid, position, false);
}
else
{
oid = idManager.GetNextObjectId(position);
}
}
else
{
// If an oid was passed, it is because object already exist and
// is being updated. So we
// must update the object position
// Here the update of the position of the id must be done in
// transaction as the object
// position of the id is being updated, and a rollback should undo
// this
// => third parameter(write in transaction) = true
idManager.UpdateObjectPositionForOid(oid, position, true);
// Keep the relation of id and position in the cache until the
// commit
cache.SavePositionOfObjectWithOid(oid, position);
}
// Sets the oid of the object in the inserting cache
cache.UpdateIdOfInsertingObject(objectInfo.GetObject(), oid);
// Only add the oid to unconnected zone if it is a new object
if (isNewObject)
{
cache.AddOIDToUnconnectedZone(oid);
if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession())
{
NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
.GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
crossSessionCache.AddObject(objectInfo.GetObject(), oid);
}
}
objectInfo.SetOid(oid);
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
NeoDatis.Tool.DLogger.Debug(DepthToSpaces() + "Start Writing non native object of type "
+ objectInfo.GetClassInfo().GetFullClassName() + " at " + position + " , oid = "
+ oid + " : " + objectInfo.ToString());
}
if (objectInfo.GetClassInfo() == null || objectInfo.GetClassInfo().GetId() == null)
{
if (objectInfo.GetClassInfo() != null)
{
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo clinfo = storageEngine.GetSession(
//.........这里部分代码省略.........
示例2: UpdateNonNativeObjectInfo
/// <summary>Updates an object.</summary>
/// <remarks>
/// Updates an object.
/// <pre>
/// Try to update in place. Only change what has changed. This is restricted to particular types (fixed size types). If in place update is
/// not possible, then deletes the current object and creates a new at the end of the database file and updates
/// OID object position.
/// @param object The object to be updated
/// @param forceUpdate when true, no verification is done to check if update must be done.
/// @return The oid of the object, as a negative number
/// @
/// </remarks>
public virtual NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
nnoi, bool forceUpdate)
{
nbCallsToUpdate++;
bool hasObject = true;
string message = null;
object @object = nnoi.GetObject();
NeoDatis.Odb.OID oid = nnoi.GetOid();
if (@object == null)
{
hasObject = false;
}
// When there is index,we must *always* load the old meta representation
// to compute index keys
bool withIndex = !nnoi.GetClassInfo().GetIndexes().IsEmpty();
NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oldMetaRepresentation =
null;
// Used to check consistency, at the end, the number of
// nbConnectedObjects must and nbUnconnected must remain unchanged
long nbConnectedObjects = nnoi.GetClassInfo().GetCommitedZoneInfo().GetNbObjects(
);
long nbNonConnectedObjects = nnoi.GetClassInfo().GetUncommittedZoneInfo().GetNbObjects
();
bool objectHasChanged = false;
try
{
NeoDatis.Odb.Core.Transaction.ISession lsession = GetSession();
long positionBeforeWrite = fsi.GetPosition();
NeoDatis.Odb.Core.Transaction.ITmpCache tmpCache = lsession.GetTmpCache();
NeoDatis.Odb.Core.Transaction.ICache cache = lsession.GetCache();
// Get header of the object (position, previous object position,
// next
// object position and class info position)
// The header must be in the cache.
NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader lastHeader = cache.GetObjectInfoHeaderFromOid
(oid, true);
if (lastHeader == null)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.UnexpectedSituation
.AddParameter("Header is null in update"));
}
if (lastHeader.GetOid() == null)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InternalError
.AddParameter("Header oid is null for oid " + oid));
}
bool objectIsInConnectedZone = cache.ObjectWithIdIsInCommitedZone(oid);
long currentPosition = lastHeader.GetPosition();
// When using client server mode, we must re-read the position of
// the object with oid. Because, another session may
// have updated the object, and in this case, the position of the
// object in the cache may be invalid
// TODO It should be done only when the object has been deleted or
// updated by another session. Should check this
// Doing this with new objects (created in the current session, the
// last committed
// object position will be negative, in this case we must use the
// currentPosition
if (!isLocalMode)
{
long lastCommitedObjectPosition = idManager.GetObjectPositionWithOid(oid, false);
if (lastCommitedObjectPosition > 0)
{
currentPosition = lastCommitedObjectPosition;
}
// Some infos that come from the client are not set
// So we overwrite them here : example : object version. Update
// date is not important here
// Because, as we are updating the object, the update date will
// be updated too
nnoi.GetHeader().SetObjectVersion(lastHeader.GetObjectVersion());
nnoi.GetHeader().SetUpdateDate(lastHeader.GetUpdateDate());
}
// for client server
if (nnoi.GetPosition() == -1)
{
nnoi.GetHeader().SetPosition(currentPosition);
}
if (currentPosition == -1)
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.InstancePositionIsNegative
.AddParameter(currentPosition).AddParameter(oid).AddParameter("In Object Info Header"
));
}
if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
{
message = DepthToSpaces() + "start updating object at " + currentPosition + ", oid="
+ oid + " : " + (nnoi != null ? nnoi.ToString() : "null");
//.........这里部分代码省略.........
示例3: InsertNonNativeObject
/// <param name="oid">The Oid of the object to be inserted</param>
/// <param name="nnoi">
/// The object meta representation The object to be inserted in
/// the database
/// </param>
/// <param name="isNewObject">To indicate if object is new</param>
/// <returns>The position of the inserted object</returns>
public virtual NeoDatis.Odb.OID InsertNonNativeObject(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
nnoi, bool isNewObject)
{
try
{
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = nnoi.GetClassInfo();
object @object = nnoi.GetObject();
// First check if object is already being inserted
// This method returns -1 if object is not being inserted
NeoDatis.Odb.OID cachedOid = GetSession().GetCache().IdOfInsertingObject(@object);
if (cachedOid != null)
{
return cachedOid;
}
// Then checks if the class of this object already exist in the
// meta model
ci = AddClass(ci, true);
// Resets the ClassInfo in the objectInfo to be sure it contains all
// updated class info data
nnoi.SetClassInfo(ci);
// Mark this object as being inserted. To manage cyclic relations
// The oid may be equal to -1
// Later in the process the cache will be updated with the right oid
GetSession().GetCache().StartInsertingObjectWithOid(@object, oid, nnoi);
// false : do not write data in transaction. Data are always written
// directly to disk. Pointers are written in transaction
NeoDatis.Odb.OID newOid = WriteNonNativeObjectInfo(oid, nnoi, -1, false, isNewObject
);
if (newOid != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant.NullObjectId)
{
GetSession().GetCache().AddObject(newOid, @object, nnoi.GetHeader());
}
return newOid;
}
finally
{
}
}
示例4: ManageIndexesForUpdate
public virtual int ManageIndexesForUpdate(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
nnoi, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo oldMetaRepresentation
)
{
// takes the indexes from the oldMetaRepresentation because noi comes
// from the client and is not always
// in sync with the server meta model (In Client Server mode)
NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex
> indexes = oldMetaRepresentation.GetClassInfo().GetIndexes();
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index = null;
NeoDatis.Tool.Wrappers.OdbComparable oldKey = null;
NeoDatis.Tool.Wrappers.OdbComparable newKey = null;
for (int i = 0; i < indexes.Count; i++)
{
index = indexes[i];
oldKey = index.ComputeKey(oldMetaRepresentation);
newKey = index.ComputeKey(nnoi);
// Only update index if key has changed!
if (oldKey.CompareTo(newKey) != 0)
{
NeoDatis.Btree.IBTree btree = index.GetBTree();
// TODO manage collision!
object old = btree.Delete(oldKey, oid);
// TODO check if old is equal to oldKey
btree.Insert(newKey, oid);
// Check consistency : index should have size equal to the class
// info element number
if (index.GetBTree().GetSize() != nnoi.GetClassInfo().GetNumberOfObjects())
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.BtreeSizeDiffersFromClassElementNumber
.AddParameter(index.GetBTree().GetSize()).AddParameter(nnoi.GetClassInfo().GetNumberOfObjects
()));
}
}
}
return indexes.Count;
}
示例5: ManageIndexesForDelete
/// <summary>Insert the object in the index</summary>
/// <param name="oid">The object id</param>
/// <param name="nnoi">The object meta represenation</param>
/// <returns>The number of indexes</returns>
/// <exception cref="System.Exception">System.Exception</exception>
public virtual int ManageIndexesForDelete(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
nnoi)
{
NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex
> indexes = nnoi.GetClassInfo().GetIndexes();
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index = null;
for (int i = 0; i < indexes.Count; i++)
{
index = indexes[i];
// TODO manage collision!
index.GetBTree().Delete(index.ComputeKey(nnoi), oid);
// Check consistency : index should have size equal to the class
// info element number
if (index.GetBTree().GetSize() != nnoi.GetClassInfo().GetNumberOfObjects())
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.BtreeSizeDiffersFromClassElementNumber
.AddParameter(index.GetBTree().GetSize()).AddParameter(nnoi.GetClassInfo().GetNumberOfObjects
()));
}
}
return indexes.Count;
}
示例6: ManageIndexesForInsert
/// <summary>Insert the object in the index</summary>
/// <param name="oid">The object id</param>
/// <param name="nnoi">The object meta represenation</param>
/// <returns>The number of indexes</returns>
public virtual int ManageIndexesForInsert(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
nnoi)
{
NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex
> indexes = nnoi.GetClassInfo().GetIndexes();
NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index = null;
for (int i = 0; i < indexes.Count; i++)
{
index = indexes[i];
try
{
index.GetBTree().Insert(index.ComputeKey(nnoi), oid);
}
catch (NeoDatis.Btree.Exception.DuplicatedKeyException e)
{
// rollback what has been done
// bug #2510966
GetSession().Rollback();
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.DuplicatedKeyInIndex
.AddParameter(index.GetName()).AddParameter(e.Message));
}
// Check consistency : index should have size equal to the class
// info element number
if (index.GetBTree().GetSize() != nnoi.GetClassInfo().GetNumberOfObjects())
{
throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.BtreeSizeDiffersFromClassElementNumber
.AddParameter(index.GetBTree().GetSize()).AddParameter(nnoi.GetClassInfo().GetNumberOfObjects
()));
}
}
return indexes.Count;
}