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


C# NeoDatis.ObjectFound方法代码示例

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


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

示例1: GetNativeObjectInfoInternal

		/// <summary>
		/// Build a meta representation of an object
		/// <pre>
		/// warning: When an object has two fields with the same name (a private field with the same name in a parent class, the deeper field (of the parent) is ignored!)
		/// </pre>
		/// </summary>
		/// <param name="o"></param>
		/// <param name="ci"></param>
		/// <param name="recursive"></param>
		/// <returns>The ObjectInfo</returns>
		protected virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo GetObjectInfoInternal
			(NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo nnoi, object o, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
			 ci, bool recursive, System.Collections.Generic.IDictionary<object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
			> alreadyReadObjects, NeoDatis.Odb.Core.Layers.Layer1.Introspector.IIntrospectionCallback
			 callback)
		{
			object value = null;
			if (o == null)
			{
				return NeoDatis.Odb.Core.Layers.Layer2.Meta.NullNativeObjectInfo.GetInstance();
			}
			System.Type clazz = o.GetType();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType type = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType
				.GetFromClass(clazz);
			string className = OdbClassUtil.GetFullName(clazz);
			if (type.IsNative())
			{
				return GetNativeObjectInfoInternal(type, o, recursive, alreadyReadObjects, 
					callback);
			}
			// sometimes the clazz.getName() may not match the ci.getClassName()
			// It happens when the attribute is an interface or superclass of the
			// real attribute class
			// In this case, ci must be updated to the real class info
			if (ci != null && !clazz.FullName.Equals(ci.GetFullClassName()))
			{
				ci = GetClassInfo(className);
				nnoi = null;
			}
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo mainAoi = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)nnoi;
			bool isRootObject = false;
			if (alreadyReadObjects == null)
			{
				alreadyReadObjects = new NeoDatis.Tool.Wrappers.Map.OdbHashMap<object, NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
					>();
				isRootObject = true;
			}
			if (o != null)
			{
                NonNativeObjectInfo cachedNnoi = null;
                alreadyReadObjects.TryGetValue(o, out cachedNnoi);
				
                if (cachedNnoi != null)
				{
					ObjectReference or = new ObjectReference(cachedNnoi);
					return or;
				}
				if (callback != null)
				{
					callback.ObjectFound(o);
				}
			}
			if (mainAoi == null)
			{
				mainAoi = BuildNnoi(o, ci, null, null, null, alreadyReadObjects);
			}
			alreadyReadObjects[o] = mainAoi;
			NeoDatis.Tool.Wrappers.List.IOdbList<System.Reflection.FieldInfo> fields = classIntrospector.GetAllFields(className);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = null;
			int attributeId = -1;
			// For all fields
			for (int i = 0; i < fields.Count; i++)
			{
				System.Reflection.FieldInfo field = fields[i];
				try
				{
					value = field.GetValue(o);
					attributeId = ci.GetAttributeId(field.Name);
					if (attributeId == -1)
					{
						throw new ODBRuntimeException(NeoDatisError.ObjectIntrospectorNoFieldWithName.AddParameter(ci.GetFullClassName()).AddParameter(field.Name));
					}
					ODBType valueType = null;
					if (value == null)
					{
						// If value is null, take the type from the field type
						// declared in the class
						valueType = ODBType.GetFromClass(field.FieldType);
					}
					else
					{
						// Else take the real attribute type!
						valueType = ODBType.GetFromClass(value.GetType());
					}
					// for native fields
					if (valueType.IsNative())
					{
						aoi = GetNativeObjectInfoInternal(valueType, value, recursive, alreadyReadObjects, callback);
						mainAoi.SetAttributeValue(attributeId, aoi);
//.........这里部分代码省略.........
开发者ID:Orvid,项目名称:SQLInterfaceCollection,代码行数:101,代码来源:LocalObjectIntrospector.cs


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