Example #1
0
 public bool CheckIfObjectExists(long id)
 {
     ObjectDetails objDetails = new ObjectDetails(id);
     object obj= objDetails.GetObjById(id);
     if( obj!=null)
         return true ;
     return false;
 }
Example #2
0
		public ObjectProperties GetObjectProperties(long id)
		{
			ObjectDetails objDetails = new ObjectDetails(id);
			ObjectUuid = objDetails.GetUUID();
			LocalId = objDetails.GetLocalID();
			Version = objDetails.GetVersion();
			return this;

		}
        public int GetDepth(long id)
        {
            try
            {
                object obj = Db4oClient.Client.Ext().GetByID(id);
                Db4oClient.Client.Ext().Activate(obj, 1);
                level++;
                IReflectClass rclass = DataLayerCommon.ReflectClassFor(obj);
                if (rclass != null)
                {
                    IReflectField[] fieldArr = DataLayerCommon.GetDeclaredFieldsInHeirarchy(rclass);
                    if (fieldArr != null)
                    {
                        foreach (IReflectField field in fieldArr)
                        {
                            object getObject    = field.Get(obj);
                            string getFieldType = field.GetFieldType().GetName();
                            IType  fieldType    = Db4oClient.TypeResolver.Resolve(getFieldType);
                            if (getObject != null)
                            {
                                if (!fieldType.IsEditable)
                                {
                                    if (fieldType.IsCollection)
                                    {
                                        ICollection coll    = (ICollection)field.Get(obj);
                                        ArrayList   arrList = new ArrayList(coll);

                                        for (int i = 0; i < arrList.Count; i++)
                                        {
                                            object colObject = arrList[i];
                                            if (colObject != null)
                                            {
                                                if (colObject is GenericObject)
                                                {
                                                    if (!m_listforObjects.Contains(colObject))
                                                    {
                                                        m_listforObjects.Add(colObject);
                                                        long objId = new ObjectDetails(colObject).GetLocalID();

                                                        level = GetDepth(objId);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else if (fieldType.IsArray)
                                    {
                                        int length = objectContainer.Ext().Reflector().Array().GetLength(field.Get(obj));
                                        for (int i = 0; i < length; i++)
                                        {
                                            object arrObject =
                                                objectContainer.Ext().Reflector().Array().Get(field.Get(obj), i);
                                            if (arrObject != null)
                                            {
                                                if (arrObject is GenericObject)
                                                {
                                                    if (!m_listforObjects.Contains(arrObject))
                                                    {
                                                        m_listforObjects.Add(arrObject);
                                                        long objId = new ObjectDetails(arrObject).GetLocalID();
                                                        level = GetDepth(objId);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!m_listforObjects.Contains(getObject))
                                        {
                                            m_listforObjects.Add(getObject);
                                            long objId = new ObjectDetails(getObject).GetLocalID();
                                            level = GetDepth(objId);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }

            return(level);
        }
Example #4
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();
		}
Example #5
0
		public static int GetDepth(long id)
		{
			ObjectDetails objDetails = new ObjectDetails(id);
			return objDetails.GetDepth(id);
		}
Example #6
0
       public static object GetObjById(long id)
		{
			ObjectDetails objDetails = new ObjectDetails(id);
			return objDetails.GetObjById(id); 

		}
Example #7
0
        public int GetDepth(long id)
        {

            try
            {

                object obj = Db4oClient.Client.Ext().GetByID(id);
                Db4oClient.Client.Ext().Activate(obj, 1);
                level++;
                IReflectClass rclass = DataLayerCommon.ReflectClassFor(obj);
                if (rclass != null)
                {
                    IReflectField[] fieldArr = DataLayerCommon.GetDeclaredFieldsInHeirarchy(rclass);
                    if (fieldArr != null)
                    {
                        foreach (IReflectField field in fieldArr)
                        {

                            object getObject = field.Get(obj);
                            string getFieldType = field.GetFieldType().GetName();
                            IType fieldType = Db4oClient.TypeResolver.Resolve(getFieldType);
                            if (getObject != null)
                            {
                                if (!fieldType.IsEditable)
                                {
                                    if (fieldType.IsCollection)
                                    {
                                        ICollection coll = (ICollection) field.Get(obj);
                                        ArrayList arrList = new ArrayList(coll);

                                        for (int i = 0; i < arrList.Count; i++)
                                        {
                                            object colObject = arrList[i];
                                            if (colObject != null)
                                            {
                                                if (colObject is GenericObject)
                                                {
                                                    if (!m_listforObjects.Contains(colObject))
                                                    {
                                                        m_listforObjects.Add(colObject);
                                                        long objId = new ObjectDetails(colObject).GetLocalID();

                                                        level = GetDepth(objId);

                                                    }
                                                }
                                            }
                                        }


                                    }
                                    else if (fieldType.IsArray)
                                    {

                                        int length = objectContainer.Ext().Reflector().Array().GetLength(field.Get(obj));
                                        for (int i = 0; i < length; i++)
                                        {
                                            object arrObject =
                                                objectContainer.Ext().Reflector().Array().Get(field.Get(obj), i);
                                            if (arrObject != null)
                                            {
                                                if (arrObject is GenericObject)
                                                {
                                                    if (!m_listforObjects.Contains(arrObject))
                                                    {
                                                        m_listforObjects.Add(arrObject);
                                                        long objId = new ObjectDetails(arrObject).GetLocalID();
                                                        level = GetDepth(objId);
                                                    }
                                                }

                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!m_listforObjects.Contains(getObject))
                                        {
                                            m_listforObjects.Add(getObject);
                                            long objId = new ObjectDetails(getObject).GetLocalID();
                                            level = GetDepth(objId);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }

            return level;
        }