当前位置: 首页>>代码示例>>C#>>正文


C# NeoDatis.SetPosition方法代码示例

本文整理汇总了C#中NeoDatis.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# NeoDatis.SetPosition方法的具体用法?C# NeoDatis.SetPosition怎么用?C# NeoDatis.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NeoDatis的用法示例。


在下文中一共展示了NeoDatis.SetPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateClassInfo

		public virtual void UpdateClassInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 classInfo, bool writeInTransaction)
		{
			// first check dependent classes
			NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo
				> dependingAttributes = classInfo.GetAllNonNativeAttributes();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = GetSession().GetMetaModel
				();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = null;
			for (int i = 0; i < dependingAttributes.Count; i++)
			{
				cai = dependingAttributes[i];
				try
				{
					NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo existingCI = metaModel.GetClassInfo
						(cai.GetFullClassname(), false);
					if (existingCI == null)
					{
						// TODO check if this getClassInfo is ok. Maybe, should
						// use
						// a buffered one
						AddClasses(classIntrospector.Introspect(cai.GetFullClassname(), true));
					}
					else
					{
						// FIXME should we update class info?
						cai.SetClassInfo(existingCI);
					}
				}
				catch (System.Exception e)
				{
					throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClassIntrospectionError
						.AddParameter(cai.GetFullClassname()), e);
				}
			}
			// To force the rewrite of class info body
			classInfo.SetAttributesDefinitionPosition(-1);
			long newCiPosition = fsi.GetAvailablePosition();
			classInfo.SetPosition(newCiPosition);
			WriteClassInfoHeader(classInfo, newCiPosition, writeInTransaction);
			WriteClassInfoBody(classInfo, fsi.GetAvailablePosition(), writeInTransaction);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:42,代码来源:AbstractObjectWriter.cs

示例2: 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(
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例3: PersistClass

		/// <summary>Persist a single class info - This method is used by the XML Importer.</summary>
		/// <remarks>Persist a single class info - This method is used by the XML Importer.</remarks>
		public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo PersistClass(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 newClassInfo, int lastClassInfoIndex, bool addClass, bool addDependentClasses)
		{
			NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = GetSession().GetMetaModel
				();
			NeoDatis.Odb.OID classInfoId = newClassInfo.GetId();
			if (classInfoId == null)
			{
				classInfoId = GetIdManager().GetNextClassId(-1);
				newClassInfo.SetId(classInfoId);
			}
			long writePosition = fsi.GetAvailablePosition();
			newClassInfo.SetPosition(writePosition);
			GetIdManager().UpdateClassPositionForId(classInfoId, writePosition, true);
			if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
			{
				NeoDatis.Tool.DLogger.Debug("Persisting class into database : " + newClassInfo.GetFullClassName
					() + " with oid " + classInfoId + " at pos " + writePosition);
				NeoDatis.Tool.DLogger.Debug("class " + newClassInfo.GetFullClassName() + " has " 
					+ newClassInfo.GetNumberOfAttributes() + " attributes : " + newClassInfo.GetAttributes
					());
			}
			// The class info oid is created in ObjectWriter.writeClassInfoHeader
			if (metaModel.GetNumberOfClasses() > 0 && lastClassInfoIndex != -2)
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo lastClassinfo = null;
				if (lastClassInfoIndex == -1)
				{
					lastClassinfo = metaModel.GetLastClassInfo();
				}
				else
				{
					lastClassinfo = metaModel.GetClassInfo(lastClassInfoIndex);
				}
				lastClassinfo.SetNextClassOID(newClassInfo.GetId());
				if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
				{
					NeoDatis.Tool.DLogger.Debug("changing next class oid. of class info " + lastClassinfo
						.GetFullClassName() + " @ " + lastClassinfo.GetPosition() + " + offset " + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
						.ClassOffsetNextClassPosition + " to " + newClassInfo.GetId() + "(" + newClassInfo
						.GetFullClassName() + ")");
				}
				fsi.SetWritePosition(lastClassinfo.GetPosition() + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
					.ClassOffsetNextClassPosition, true);
				fsi.WriteLong(newClassInfo.GetId().GetObjectId(), true, "next class oid", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
					.PointerWriteAction);
				newClassInfo.SetPreviousClassOID(lastClassinfo.GetId());
			}
			if (addClass)
			{
				metaModel.AddClass(newClassInfo);
			}
			// updates number of classes
			WriteNumberOfClasses(metaModel.GetNumberOfClasses(), true);
			// If it is the first class , updates the first class OID
			if (newClassInfo.GetPreviousClassOID() == null)
			{
				WriteFirstClassInfoOID(newClassInfo.GetId(), true);
			}
			// Writes the header of the class - out of transaction (FIXME why out of
			// transaction)
			WriteClassInfoHeader(newClassInfo, writePosition, false);
			if (addDependentClasses)
			{
				NeoDatis.Tool.Wrappers.List.IOdbList<NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo
					> dependingAttributes = newClassInfo.GetAllNonNativeAttributes();
				NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassAttributeInfo cai = null;
				for (int i = 0; i < dependingAttributes.Count; i++)
				{
					cai = dependingAttributes[i];
					try
					{
						NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo existingCI = metaModel.GetClassInfo
							(cai.GetFullClassname(), false);
						if (existingCI == null)
						{
							// TODO check if this getClassInfo is ok. Maybe, should
							// use
							// a buffered one
							AddClasses(classIntrospector.Introspect(cai.GetFullClassname(), true));
						}
						else
						{
							// Even,if it exist,take the one from metamodel
							cai.SetClassInfo(existingCI);
						}
					}
					catch (System.Exception e)
					{
						throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClassIntrospectionError
							.AddParameter(cai.GetFullClassname()), e);
					}
				}
			}
			WriteClassInfoBody(newClassInfo, fsi.GetAvailablePosition(), true);
			return newClassInfo;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:99,代码来源:AbstractObjectWriter.cs


注:本文中的NeoDatis.SetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。