Ejemplo n.º 1
0
        private SimpleFieldDescription CreateField(TypeName declaredOn, IReflectField field,
                                                   Func <IReflectClass, ITypeDescription> typeLookUp)
        {
            var fieldType = typeLookUp(field.GetFieldType());

            return(SimpleFieldDescription.Create(field.GetName(),
                                                 fieldType, IndexLookUp(declaredOn, field.GetName(), fieldType.TypeName)));
        }
Ejemplo n.º 2
0
        public IType GetFieldType()
        {
            GenericReflector reflecotr = objectContainer.Ext().Reflector();
            IReflectClass    klass     = reflecotr.ForName(m_classname);

            IReflectField rfield = DataLayerCommon.GetDeclaredFieldInHeirarchy(klass, m_fieldname);

            return(Db4oClient.TypeResolver.Resolve(rfield.GetFieldType()));
        }
Ejemplo n.º 3
0
        public Db4oField(IReflectField storedField)
        {
            internalName = storedField.GetName();
            name = AutomaticPropertyUtils.TryParseName(internalName);

            IReflectClass fieldType = storedField.GetFieldType();
            if(fieldType!=null)
                DataType = fieldType.ToString();
        }
Ejemplo n.º 4
0
        private static FieldProperties FieldPropertiesFor(string className, IReflectField field)
        {
            FieldProperties fp = new FieldProperties(field.GetName(), field.GetFieldType().GetName());
            FieldDetails    fd = new FieldDetails(className, fp.Field);

            fp.m_isPublic  = fd.GetModifier();
            fp.m_isIndexed = fd.IsIndexed();

            return(fp);
        }
Ejemplo n.º 5
0
            public object Apply(object current)
            {
                IReflectField field = (IReflectField)current;

                if (field.GetFieldType() != stringClass)
                {
                    return(Iterators.Skip);
                }
                return(new SampleTestCase.FieldOnObject(field, obj));
            }
Ejemplo n.º 6
0
 public object getClass(string attribName, object subObject, string fullattribName)
 {
     try
     {
         IReflectClass rclass = DataLayerCommon.ReflectClassFor(subObject);
         if (rclass != null)
         {
             IReflectField rfield = DataLayerCommon.GetDeclaredFieldInHeirarchy(rclass, attribName);
             if (rfield != null)
             {
                 string fieldType = rfield.GetFieldType().GetName();
                 IType  type      = Db4oClient.TypeResolver.Resolve(fieldType);
                 if (m_hashRowContent == null)
                 {
                     m_hashRowContent = new Hashtable();
                 }
                 if (!type.IsEditable)
                 {
                     if (!rfield.GetFieldType().IsCollection() && !rfield.GetFieldType().IsArray())
                     {
                         object getObj = rfield.Get(subObject);
                         if (getObj == null)
                         {
                             m_hashRowContent.Add(fullattribName, BusinessConstants.DB4OBJECTS_NULL);
                         }
                         return(getObj);
                     }
                 }
                 else
                 {
                     object objValue = rfield.Get(subObject);
                     m_hashRowContent.Add(fullattribName, objValue);
                 }
             }
         }
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
     }
     return(null);
 }
 public List <TreeGridViewRenderer> CreateCollectionNode(IReflectField field, object ownerObject, int count)
 {
     try
     {
         TreeGridViewRenderer TreeviewRenderer = new TreeGridViewRenderer();
         TreeviewRenderer.DisplayFieldName = field.GetName() + " ( " + count + " items )";
         TreeviewRenderer.FieldName        = field.GetName();
         TreeviewRenderer.FieldType        = field.GetName();
         TreeviewRenderer.QualifiedName    = field.GetFieldType().GetName();
         TreeviewRenderer.ObjectId         = 0;
         if (ownerObject != null)
         {
             TreeviewRenderer.FieldValue = ownerObject.ToString();
         }
         else
         {
             TreeviewRenderer.FieldValue = BusinessConstants.DB4OBJECTS_NULL;
         }
         if (count == 0)
         {
             TreeviewRenderer.HasSubNode = false;
         }
         else
         {
             TreeviewRenderer.HasSubNode = true;
             long id = GetLocalID(ownerObject);
             if (ownerObject is GenericObject || ownerObject is GenericArray)
             {
                 TreeviewRenderer.ObjectId = id;
             }
             else
             if (id != 0)
             {
                 TreeviewRenderer.ObjectId = id;
             }
             else
             {
                 TreeviewRenderer.SubObject = ownerObject;
             }
         }
         IType type = ResolveFieldType(field);
         TreeviewRenderer.FieldType      = SetFieldType(type);
         TreeviewRenderer.ObjectType     = type;
         TreeviewRenderer.ReadOnlyStatus = true;
         listTreeGridViewRenderers.Add(TreeviewRenderer);
         return(listTreeGridViewRenderers);
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
         return(null);
     }
 }
Ejemplo n.º 8
0
 private FieldInfo[] MapFields(IReflectField[] fields, bool shouldStoreTransientFields
                               )
 {
     if (!shouldStoreTransientFields)
     {
         fields = FilterTransientFields(fields);
     }
     FieldInfo[] fieldsMeta = new FieldInfo[fields.Length];
     for (int i = 0; i < fields.Length; ++i)
     {
         IReflectField field      = fields[i];
         bool          isArray    = field.GetFieldType().IsArray();
         IReflectClass fieldClass = isArray ? field.GetFieldType().GetComponentType() : field
                                    .GetFieldType();
         bool isPrimitive = fieldClass.IsPrimitive();
         // TODO: need to handle NArray, currently it ignores NArray and alway sets NArray flag false.
         fieldsMeta[i] = new FieldInfo(field.GetName(), GetClassMeta(fieldClass), isPrimitive
                                       , isArray, false);
     }
     return(fieldsMeta);
 }
Ejemplo n.º 9
0
		internal FieldMetadata(ClassMetadata containingClass, IReflectField field, ClassMetadata
			 fieldType) : this(containingClass)
		{
			Init(field.GetName());
			_reflectField = field;
			_fieldType = fieldType;
			_fieldTypeID = fieldType.GetID();
			// TODO: beautify !!!  possibly pull up isPrimitive to ReflectField
			bool isPrimitive = field is GenericField ? ((GenericField)field).IsPrimitive() : 
				false;
			Configure(field.GetFieldType(), isPrimitive);
			CheckDb4oType();
			SetAvailable();
		}
Ejemplo n.º 10
0
 internal FieldMetadata(ClassMetadata containingClass, IReflectField field, ClassMetadata
                        fieldType) : this(containingClass)
 {
     Init(field.GetName());
     _reflectField = field;
     _fieldType    = fieldType;
     _fieldTypeID  = fieldType.GetID();
     // TODO: beautify !!!  possibly pull up isPrimitive to ReflectField
     bool isPrimitive = field is GenericField ? ((GenericField)field).IsPrimitive() :
                        false;
     Configure(field.GetFieldType(), isPrimitive);
     CheckDb4oType();
     SetAvailable();
 }
Ejemplo n.º 11
0
 public bool IsPrimitive()
 {
     try
     {
         IReflectClass rClass = DataLayerCommon.ReflectClassForName(m_classname);
         IReflectField rField = DataLayerCommon.GetDeclaredFieldInHeirarchy(rClass, m_fieldname);
         return(rField.GetFieldType().IsPrimitive());
     }
     catch (Exception oEx)
     {
         LoggingHelper.HandleException(oEx);
         return(false);
     }
 }
Ejemplo n.º 12
0
 private void ScanThroughKnownClassesInfo(IObjectContainer db)
 {
     IReflectClass[] clazzArray = db.Ext().KnownClasses();
     for (int clazzIndex = 0; clazzIndex < clazzArray.Length; ++clazzIndex)
     {
         IReflectClass   clazz      = clazzArray[clazzIndex];
         IReflectField[] fieldArray = clazz.GetDeclaredFields();
         for (int fieldIndex = 0; fieldIndex < fieldArray.Length; ++fieldIndex)
         {
             IReflectField field = fieldArray[fieldIndex];
             field.GetName();
             field.GetFieldType();
         }
     }
 }
Ejemplo n.º 13
0
 private void CheckDb4oType()
 {
     if (_reflectField != null)
     {
         if (Container()._handlers.IclassDb4otype.IsAssignableFrom(_reflectField.GetFieldType
                                                                       ()))
         {
             _db4oType = HandlerRegistry.GetDb4oType(_reflectField.GetFieldType());
         }
     }
 }
Ejemplo n.º 14
0
        private static object SetField(string attribName, object subObject, object newValue)
        {
            try
            {
                IReflectClass rclass = DataLayerCommon.ReflectClassFor(subObject);
                if (rclass == null)
                {
                    return(null);
                }

                IReflectField rfield = DataLayerCommon.GetDeclaredFieldInHeirarchy(rclass, attribName);
                if (rfield == null)
                {
                    return(null);
                }

                if (rfield is GenericVirtualField || rfield.IsStatic())
                {
                    return(null);
                }



                IType fieldType = Db4oClient.TypeResolver.Resolve(rfield.GetFieldType());
                if (!fieldType.IsEditable)
                {
                    if (!fieldType.IsCollection && !fieldType.IsArray)
                    {
                        subObject = rfield.Get(subObject);
                        Db4oClient.Client.Ext().Activate(subObject, 2);
                        return(subObject);
                    }
                }
                else if (subObject != null)
                {
                    rfield.Set(subObject, fieldType.Cast(newValue));
                    return(subObject);
                }
                return(null);
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
                return(null);
            }
        }
Ejemplo n.º 15
0
            public bool Match(object candidate)
            {
                IReflectField field = (IReflectField)candidate;

                if (field.IsStatic())
                {
                    return(false);
                }
                if (field.IsTransient())
                {
                    return(false);
                }
                if (Platform4.IsTransient(field.GetFieldType()))
                {
                    return(false);
                }
                return(true);
            }
Ejemplo n.º 16
0
        /// <exception cref="System.Exception"></exception>
        protected virtual void AssertNullItem(object obj)
        {
            IReflectClass claxx = Reflector().ForObject(obj);

            IReflectField[] fields = claxx.GetDeclaredFields();
            for (int i = 0; i < fields.Length; ++i)
            {
                IReflectField field = fields[i];
                if (field.IsStatic() || field.IsTransient())
                {
                    continue;
                }
                IReflectClass type = field.GetFieldType();
                if (Container().ClassMetadataForReflectClass(type).IsValueType())
                {
                    continue;
                }
                object value = field.Get(obj);
                Assert.IsNull(value);
            }
        }
Ejemplo n.º 17
0
        private ClassMetadata DetectFieldType()
        {
            IReflectClass claxx = _containingClass.ClassReflector();

            if (claxx == null)
            {
                return(null);
            }
            _reflectField = claxx.GetDeclaredField(_name);
            if (_reflectField == null)
            {
                return(null);
            }
            IReflectClass fieldType = _reflectField.GetFieldType();

            if (fieldType == null)
            {
                return(null);
            }
            return(Handlers4.ErasedFieldType(Container(), fieldType));
        }
Ejemplo n.º 18
0
 private SimpleFieldDescription CreateField(TypeName declaredOn, IReflectField field,
     Func<IReflectClass, ITypeDescription> typeLookUp)
 {
     var fieldType = typeLookUp(field.GetFieldType());
     return SimpleFieldDescription.Create(field.GetName(),
                                          fieldType, IndexLookUp(declaredOn, field.GetName(), fieldType.TypeName));
 }
Ejemplo n.º 19
0
	    private void RenderSubObject(long id, IReflectField field)
		{
			try
			{
				object currObj = Db4oClient.Client.Ext().GetByID(id);
				object value = field.Get(currObj);
                 IType type = ResolveFieldType(field);
				if (value != null)
				{
					container.Ext().Activate(value, 1);
                    if(value.GetType().IsArray)
                    {
                        RenderArray(id, field);
                        return;
                    }
				}
                if (GetLocalID(value) == 0)
                {
                    CreateSimplePrimitiveNode(field, value, type);
                }
                else
                {


                   
                    TreeGridViewRenderer treeGridViewRenderer = new TreeGridViewRenderer();
                    treeGridViewRenderer.DisplayFieldName = AppendIDTo(field.GetName(), GetLocalID(value), type);
                    treeGridViewRenderer.FieldName = field.GetName();
                    treeGridViewRenderer.FieldValue = value != null ? type.FullName : BusinessConstants.DB4OBJECTS_NULL;
                    treeGridViewRenderer.QualifiedName = field.GetFieldType().GetName();
                    treeGridViewRenderer.FieldType = SetFieldType(type);
                    treeGridViewRenderer.ReadOnlyStatus = readOnly;
                    treeGridViewRenderer.ObjectId = GetLocalID(value);
                    treeGridViewRenderer.ObjectType = type;
                    treeGridViewRenderer.HasSubNode = type.IsCollection || type.IsArray;
                    if (treeGridViewRenderer.HasSubNode)
                    {
                        long longid = GetLocalID(value);
                        if (value is GenericObject)
                            treeGridViewRenderer.ObjectId = longid;

                        else if (longid != 0)
                            treeGridViewRenderer.ObjectId = longid;
                        else
                        {
                            treeGridViewRenderer.SubObject = value;
                        }
                    }
                    listTreeGridViewRenderers.Add(treeGridViewRenderer);
                    if (currObj is DictionaryEntry && field.GetName() == BusinessConstants.DB4OBJECTS_KEY)
                        treeGridViewRenderer.ReadOnlyStatus = true;
                    else if (currObj is DictionaryEntry && field.GetName() == BusinessConstants.DB4OBJECTS_VALUE)
                        treeGridViewRenderer.ReadOnlyStatus = readOnly;
                    else if (field.Get(currObj) == null)
                        treeGridViewRenderer.ReadOnlyStatus = true;
                    else
                        treeGridViewRenderer.ReadOnlyStatus = true;
                }

			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
			}
		}
Ejemplo n.º 20
0
	    public List<TreeGridViewRenderer > CreateCollectionNode(IReflectField field, object ownerObject, int count)
		{
			try
			{
				TreeGridViewRenderer TreeviewRenderer = new TreeGridViewRenderer();
				TreeviewRenderer.DisplayFieldName = field.GetName() + " ( " + count + " items )";
			    TreeviewRenderer.FieldName = field.GetName();
                TreeviewRenderer.FieldType = field.GetName();
			    TreeviewRenderer.QualifiedName = field.GetFieldType().GetName();  
				TreeviewRenderer.ObjectId = 0;
				if (ownerObject != null)
				TreeviewRenderer.FieldValue = ownerObject.ToString();
				else
					TreeviewRenderer.FieldValue = BusinessConstants.DB4OBJECTS_NULL;
				if (count == 0)
					TreeviewRenderer.HasSubNode  = false;
				else
				{
					TreeviewRenderer.HasSubNode  = true;
					long id = GetLocalID(ownerObject);
					if (ownerObject is GenericObject || ownerObject is GenericArray )
						TreeviewRenderer.ObjectId = id;
					else
						if (id != 0)
							TreeviewRenderer.ObjectId = id;
						else
							TreeviewRenderer.SubObject = ownerObject;
				}
				IType type = ResolveFieldType(field);
				TreeviewRenderer.FieldType = SetFieldType(type );
				TreeviewRenderer.ObjectType = type;
				TreeviewRenderer.ReadOnlyStatus = true ;
				listTreeGridViewRenderers.Add(TreeviewRenderer);
				return listTreeGridViewRenderers;
			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
				return null;
			}
		}
        private void RenderSubObject(long id, IReflectField field)
        {
            try
            {
                object currObj = Db4oClient.Client.Ext().GetByID(id);
                object value   = field.Get(currObj);
                IType  type    = ResolveFieldType(field);
                if (value != null)
                {
                    container.Ext().Activate(value, 1);
                    if (value.GetType().IsArray)
                    {
                        RenderArray(id, field);
                        return;
                    }
                }
                if (GetLocalID(value) == 0)
                {
                    CreateSimplePrimitiveNode(field, value, type);
                }
                else
                {
                    TreeGridViewRenderer treeGridViewRenderer = new TreeGridViewRenderer();
                    treeGridViewRenderer.DisplayFieldName = AppendIDTo(field.GetName(), GetLocalID(value), type);
                    treeGridViewRenderer.FieldName        = field.GetName();
                    treeGridViewRenderer.FieldValue       = value != null ? type.FullName : BusinessConstants.DB4OBJECTS_NULL;
                    treeGridViewRenderer.QualifiedName    = field.GetFieldType().GetName();
                    treeGridViewRenderer.FieldType        = SetFieldType(type);
                    treeGridViewRenderer.ReadOnlyStatus   = readOnly;
                    treeGridViewRenderer.ObjectId         = GetLocalID(value);
                    treeGridViewRenderer.ObjectType       = type;
                    treeGridViewRenderer.HasSubNode       = type.IsCollection || type.IsArray;
                    if (treeGridViewRenderer.HasSubNode)
                    {
                        long longid = GetLocalID(value);
                        if (value is GenericObject)
                        {
                            treeGridViewRenderer.ObjectId = longid;
                        }

                        else if (longid != 0)
                        {
                            treeGridViewRenderer.ObjectId = longid;
                        }
                        else
                        {
                            treeGridViewRenderer.SubObject = value;
                        }
                    }
                    listTreeGridViewRenderers.Add(treeGridViewRenderer);
                    if (currObj is DictionaryEntry && field.GetName() == BusinessConstants.DB4OBJECTS_KEY)
                    {
                        treeGridViewRenderer.ReadOnlyStatus = true;
                    }
                    else if (currObj is DictionaryEntry && field.GetName() == BusinessConstants.DB4OBJECTS_VALUE)
                    {
                        treeGridViewRenderer.ReadOnlyStatus = readOnly;
                    }
                    else if (field.Get(currObj) == null)
                    {
                        treeGridViewRenderer.ReadOnlyStatus = true;
                    }
                    else
                    {
                        treeGridViewRenderer.ReadOnlyStatus = true;
                    }
                }
            }
            catch (Exception oEx)
            {
                LoggingHelper.HandleException(oEx);
            }
        }
Ejemplo n.º 22
0
    	private static FieldProperties FieldPropertiesFor(string className, IReflectField field)
    	{
    		FieldProperties fp = new FieldProperties(field.GetName(), field.GetFieldType().GetName());
    		FieldDetails fd = new FieldDetails(className, fp.Field);
    		fp.m_isPublic = fd.GetModifier();
    		fp.m_isIndexed = fd.IsIndexed();
    		
			return fp;
    	}
Ejemplo n.º 23
0
 private bool IsTransient(IReflectField field)
 {
     return field.IsTransient() || Platform4.IsTransient(field.GetFieldType());
 }
Ejemplo n.º 24
0
            private bool IsActivating(IReflectField field)
            {
                IReflectClass fieldType = field.GetFieldType();

                return(fieldType != null && !fieldType.IsPrimitive());
            }
        public IType ResolveFieldType(IReflectField field)
        {
            IReflectClass type = field.GetFieldType();

            return(type != null?ResolveType(type) : null);
        }
Ejemplo n.º 26
0
		private ClassMetadata DetectFieldType()
		{
			IReflectClass claxx = _containingClass.ClassReflector();
			if (claxx == null)
			{
				return null;
			}
			_reflectField = claxx.GetDeclaredField(_name);
			if (_reflectField == null)
			{
				return null;
			}
			IReflectClass fieldType = _reflectField.GetFieldType();
			if (fieldType == null)
			{
				return null;
			}
			return Handlers4.ErasedFieldType(Container(), fieldType);
		}
Ejemplo n.º 27
0
		public IType ResolveFieldType(IReflectField field)
		{
			IReflectClass type = field.GetFieldType();
			return type != null ? ResolveType(type) : null;
		}
			private bool IsActivating(IReflectField field)
			{
				IReflectClass fieldType = field.GetFieldType();
				return fieldType != null && !fieldType.IsPrimitive();
			}