Example #1
0
		public ObjectProperties GetObjectProperties(long id)
		{
			ObjectDetails objDetails = new ObjectDetails(id);
			ObjectUuid = objDetails.GetUUID();
			LocalId = objDetails.GetLocalID();
			Version = objDetails.GetVersion();
			return this;

		}
Example #2
0
		/**
		 * Each node in "details view" holds a reference for its corresponding
		 * object in the object model. While this works fine with reference
		 * types, it fails miserably with nested value types. 
		 * 
		 * For more details see OMNUnitTest.RenderHierarchyTestCase.
		 */


        //public static bool TryUpdateValueType(TreeGridNode node, object newValue)
        //{
        //    if (node == null || node.Parent == null)
        //        return false;

        //    ValueTypeChange change = ValueTypeChangeFor(node.Parent, 0);
        //    if (change == null)
        //        return false;

        //    FieldInfo fieldInfo = FieldInfoFor(node);
        //    if (fieldInfo == null)
        //        return false;

        //    fieldInfo.SetValueDirect(TypedReference.MakeTypedReference(change.TargetObject, change.FieldPath.ToArray()), newValue);
        //    return true;
        //}

        //private static ValueTypeChange ValueTypeChangeFor(TreeGridNode node, int depth)
        //{
        //    IType omnType = FieldTypeFor(node);
        //    if (omnType.IsCollection || omnType.IsArray)
        //        return null;

        //    Type type = Type.GetType(omnType.FullName);
        //    if (type == null)
        //        return null;

        //    if (type.IsValueType)
        //    {
        //        ValueTypeChange change = ValueTypeChangeFor(node.Parent, depth + 1);
        //        if (change != null)
        //            change.FieldPath.Add(FieldInfoFor(node));

        //        return change;
        //    }

        //    return depth == 0 ? null : new ValueTypeChange(node.Tag);
        //}


        //private static FieldInfo FieldInfoFor(TreeGridNode node)
        //{
        //    Type parentType = Type.GetType(FieldTypeFor(node.Parent).FullName);
        //    return (parentType != null)
        //            ? parentType.GetField(FieldNameFor(node), BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)
        //            : null;
        //}

        //private static string FieldNameFor(TreeGridNode node)
        //{
        //    return (string)node.Cells[0].Value;
        //}

        //private static IType FieldTypeFor(TreeGridNode node)
        //{
        //    long id = (long)node.Tag;
        //    object obj = Db4oClient.Client.Ext().GetByID(id);
        //    IType type  = ResolveType(DataLayerCommon.ReflectClassFor(obj));
        //    return type;
        //}
		
        public long GetLocalID(object obj)
		{
			ObjectDetails objDetails = new ObjectDetails(obj);
			return objDetails.GetLocalID();
		}