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


C# NeoDatis.GetObject方法代码示例

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


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

示例1: AtomicNativeObjectToString

		public static string AtomicNativeObjectToString(NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo
			 anoi, int caller)
		{
			if (anoi == null || anoi.IsNull())
			{
				return "null";
			}
			if (anoi.GetObject() is System.DateTime)
			{
				if (NeoDatis.Odb.Impl.Tool.ObjectTool.CallerIsOdbExplorer(caller))
				{
					return format.Format((System.DateTime)anoi.GetObject());
				}
				return ((System.DateTime)anoi.GetObject()).Millisecond.ToString();
			}
			return anoi.GetObject().ToString();
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:17,代码来源:ObjectTool.cs

示例2: WriteAtomicNativeObject

		public virtual long WriteAtomicNativeObject(NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo
			 anoi, bool writeInTransaction, int totalSpaceIfString)
		{
			long startPosition = fsi.GetPosition();
			int odbTypeId = anoi.GetOdbTypeId();
			WriteNativeObjectHeader(odbTypeId, anoi.IsNull(), NeoDatis.Odb.Impl.Core.Layers.Layer3.Block.BlockTypes
				.BlockTypeNativeObject, writeInTransaction);
			if (anoi.IsNull())
			{
				// Even if object is null, reserve space for to simplify/enable in
				// place update
				fsi.EnsureSpaceFor(anoi.GetOdbType());
				return startPosition;
			}
			object @object = anoi.GetObject();
			switch (odbTypeId)
			{
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.ByteId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeByteId:
				{
					fsi.WriteByte(((byte)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.BooleanId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeBooleanId:
				{
					fsi.WriteBoolean(((bool)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.CharacterId:
				{
					fsi.WriteChar(((char)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeCharId:
				{
					fsi.WriteChar(@object.ToString()[0], writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.FloatId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeFloatId:
				{
					fsi.WriteFloat(((float)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.DoubleId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeDoubleId:
				{
					fsi.WriteDouble(((double)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.IntegerId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeIntId:
				{
					fsi.WriteInt(((int)@object), writeInTransaction, "native attr");
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.LongId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeLongId:
				{
					fsi.WriteLong(((long)@object), writeInTransaction, "native attr", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction
						.DataWriteAction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.ShortId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeShortId:
				{
					fsi.WriteShort(((short)@object), writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.BigDecimalId:
				{
					fsi.WriteBigDecimal((System.Decimal)@object, writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.BigIntegerId:
				{
					fsi.WriteBigInteger((System.Decimal)@object, writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.DateId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.DateSqlId:
				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.DateTimestampId:
				{
					fsi.WriteDate((System.DateTime)@object, writeInTransaction);
					break;
				}

				case NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.StringId:
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例3: 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

示例4: WriteEnumNativeObject

		public virtual long WriteEnumNativeObject(NeoDatis.Odb.Core.Layers.Layer2.Meta.EnumNativeObjectInfo
			 anoi, bool writeInTransaction)
		{
			long startPosition = fsi.GetPosition();
			int odbTypeId = anoi.GetOdbTypeId();
			WriteNativeObjectHeader(odbTypeId, anoi.IsNull(), NeoDatis.Odb.Impl.Core.Layers.Layer3.Block.BlockTypes
				.BlockTypeNativeObject, writeInTransaction);
			// Writes the Enum ClassName
			fsi.WriteLong(anoi.GetEnumClassInfo().GetId().GetObjectId(), writeInTransaction, 
				"enum class info id", NeoDatis.Odb.Impl.Core.Transaction.DefaultWriteAction.DataWriteAction
				);
			// Write the Enum String value
			fsi.WriteString(anoi.GetObject().ToString(), writeInTransaction, true, -1);
			return startPosition;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:15,代码来源:AbstractObjectWriter.cs

示例5: SafeOverWriteAtomicNativeObject

		/// <exception cref="Java.Lang.NumberFormatException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public virtual long SafeOverWriteAtomicNativeObject(long position, NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo
			 newAnoi, bool writeInTransaction)
		{
			// If the attribute an a non fix ize, check if this write is safe
			if (NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.HasFixSize(newAnoi.GetOdbTypeId(
				)))
			{
				fsi.SetWritePosition(position, writeInTransaction);
				return WriteAtomicNativeObject(newAnoi, writeInTransaction);
			}
			if (NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.IsStringOrBigDicemalOrBigInteger
				(newAnoi.GetOdbTypeId()))
			{
				fsi.SetReadPosition(position + NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
					.NativeObjectOffsetDataArea);
				int totalSize = fsi.ReadInt("String total size");
				int stringNumberOfBytes = byteArrayConverter.GetNumberOfBytesOfAString(newAnoi.GetObject
					().ToString(), true);
				// Checks if there is enough space to store this new string in place
				bool canUpdate = totalSize >= stringNumberOfBytes;
				if (canUpdate)
				{
					fsi.SetWritePosition(position, writeInTransaction);
					return WriteAtomicNativeObject(newAnoi, writeInTransaction, totalSize);
				}
			}
			return -1;
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:30,代码来源:AbstractObjectWriter.cs

示例6: 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.
		/// &#064;param object The object to be updated
		/// &#064;param forceUpdate when true, no verification is done to check if update must be done.
		/// &#064;return The oid of the object, as a negative number
		/// &#064;
		/// </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");
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:AbstractObjectWriter.cs

示例7: StoreObject

		/// <summary>
		/// Store a meta representation of an object(already as meta
		/// representation)in ODBFactory database.
		/// </summary>
		/// <remarks>
		/// Store a meta representation of an object(already as meta
		/// representation)in ODBFactory database.
		/// To detect if object must be updated or insert, we use the cache. To
		/// update an object, it must be first selected from the database. When an
		/// object is to be stored, if it exist in the cache, then it will be
		/// updated, else it will be inserted as a new object. If the object is null,
		/// the cache will be used to check if the meta representation is in the
		/// cache
		/// </remarks>
		/// <param name="oid">The oid of the object to be inserted/updates</param>
		/// <param name="nnoi">The meta representation of an object</param>
		/// <returns>The object position</returns>
		public virtual NeoDatis.Odb.OID StoreObject(NeoDatis.Odb.OID oid, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			 nnoi)
		{
			// first detects if we must perform an insert or an update
			// If object is in the cache, we must perform an update, else an insert
			object @object = nnoi.GetObject();
			bool mustUpdate = false;
			NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
			if (@object != null)
			{
				NeoDatis.Odb.OID cacheOid = cache.IdOfInsertingObject(@object);
				if (cacheOid != null)
				{
					return cacheOid;
				}
				// throw new ODBRuntimeException("Inserting meta representation of
				// an object without the object itself is not yet supported");
				mustUpdate = cache.ExistObject(@object);
			}
			if (!mustUpdate)
			{
				mustUpdate = nnoi.GetOid() != NeoDatis.Odb.Impl.Core.Layers.Layer3.Engine.StorageEngineConstant
					.NullObjectId;
			}
			// To enable auto - reconnect object loaded from previous sessions
			// auto reconnect is on
			if (!mustUpdate && NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession())
			{
				NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
					.GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
				if (crossSessionCache.ExistObject(@object))
				{
					storageEngine.Reconnect(@object);
					mustUpdate = true;
				}
			}
			if (mustUpdate)
			{
				return UpdateNonNativeObjectInfo(nnoi, false);
			}
			return InsertNonNativeObject(oid, nnoi, true);
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:59,代码来源:AbstractObjectWriter.cs

示例8: 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
			{
			}
		}
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:45,代码来源:AbstractObjectWriter.cs


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