Exemplo n.º 1
0
 private IEnumerable <SimpleFieldDescription> ExtractFields(TypeName declaringTypeName, IReflectClass classInfo,
                                                            Func <IReflectClass, ITypeDescription> typeLookUp)
 {
     return(classInfo.GetDeclaredFields()
            .Where(f => !(f is GenericVirtualField))
            .Select(f => CreateField(declaringTypeName, f, typeLookUp)));
 }
Exemplo n.º 2
0
        private void SetFieldsToNull(object @object, IReflectClass claxx)
        {
            IReflectField[] fields;
            fields = claxx.GetDeclaredFields();
            for (int i = 0; i < fields.Length; i++)
            {
                IReflectField field = fields[i];
                if (field.IsStatic())
                {
                    continue;
                }
                if (field.IsTransient())
                {
                    continue;
                }
                field.Set(@object, null);
            }
            IReflectClass superclass = claxx.GetSuperclass();

            if (superclass == null)
            {
                return;
            }
            SetFieldsToNull(@object, superclass);
        }
Exemplo n.º 3
0
 public virtual IReflectField[] GetDeclaredFields()
 {
     if (_delegate != null)
     {
         return(_delegate.GetDeclaredFields());
     }
     return(_fields);
 }
		private ClassInfo NewUserClassMeta(IReflectClass claxx)
		{
			ClassInfo classMeta = ClassInfo.NewUserClass(claxx.GetName());
			classMeta.SetSuperClass(MapSuperclass(claxx));
			RegisterClassMeta(claxx.GetName(), classMeta);
			classMeta.SetFields(MapFields(claxx.GetDeclaredFields(), ShouldStoreTransientFields
				(claxx)));
			return classMeta;
		}
Exemplo n.º 5
0
        private ClassInfo NewUserClassMeta(IReflectClass claxx)
        {
            ClassInfo classMeta = ClassInfo.NewUserClass(claxx.GetName());

            classMeta.SetSuperClass(MapSuperclass(claxx));
            RegisterClassMeta(claxx.GetName(), classMeta);
            classMeta.SetFields(MapFields(claxx.GetDeclaredFields(), ShouldStoreTransientFields
                                              (claxx)));
            return(classMeta);
        }
Exemplo n.º 6
0
 public static void ForEachField(IReflectClass claxx, IProcedure4 procedure)
 {
     while (claxx != null)
     {
         var declaredFields = claxx.GetDeclaredFields();
         for (var reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex)
         {
             var reflectField = declaredFields[reflectFieldIndex];
             procedure.Apply(reflectField);
         }
         claxx = claxx.GetSuperclass();
     }
 }
Exemplo n.º 7
0
		public static void ForEachField(IReflectClass claxx, IProcedure4 procedure)
		{
			while (claxx != null)
			{
				IReflectField[] declaredFields = claxx.GetDeclaredFields();
				for (int reflectFieldIndex = 0; reflectFieldIndex < declaredFields.Length; ++reflectFieldIndex)
				{
					IReflectField reflectField = declaredFields[reflectFieldIndex];
					procedure.Apply(reflectField);
				}
				claxx = claxx.GetSuperclass();
			}
		}
Exemplo n.º 8
0
        public virtual void CopyState(object to, object from)
        {
            IReflectClass fromClass = Reflector().ForObject(from);

            // FIXME: We need to get the classes parents fields copied too.
            foreach (IReflectField f in fromClass.GetDeclaredFields())
            {
                if (f.IsStatic())
                {
                    continue;
                }
                f.Set(to, f.Get(from));
            }
        }
Exemplo n.º 9
0
            private bool HasNoActivatingFields(IReflectClass clazz)
            {
                IReflectClass curClass = clazz;

                while (curClass != null)
                {
                    IReflectField[] fields = curClass.GetDeclaredFields();
                    if (!this.HasNoActivatingFields(fields))
                    {
                        return(false);
                    }
                    curClass = curClass.GetSuperclass();
                }
                return(true);
            }
Exemplo n.º 10
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();
         }
     }
 }
Exemplo n.º 11
0
 public static List <IReflectField> NonVirtualFieldsFor(IReflectClass aClass)
 {
     try
     {
         List <IReflectField> ret = new List <IReflectField>();
         foreach (IReflectField field in aClass.GetDeclaredFields())
         {
             if (!(field is GenericVirtualField))
             {
                 ret.Add(field);
             }
         }
         return(ret);
     }
     catch (Exception e)
     {
         LoggingHelper.HandleException(e);
     }
     return(null);
 }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
0
		public static IEnumerator PersistentFields(IReflectClass claxx)
		{
			return Iterators.Filter(claxx.GetDeclaredFields(), new _IPredicate4_31());
		}
Exemplo n.º 14
0
        private IReflectField[] DeclaredFields(object obj)
        {
            IReflectClass claxx = Reflector().ForObject(obj);

            return(claxx.GetDeclaredFields());
        }
Exemplo n.º 15
0
 public static IEnumerator PersistentFields(IReflectClass claxx)
 {
     return(Iterators.Filter(claxx.GetDeclaredFields(), new _IPredicate4_31()));
 }
Exemplo n.º 16
0
 public static List<IReflectField> NonVirtualFieldsFor(IReflectClass aClass)
 {
     try
     {
         List<IReflectField> ret = new List<IReflectField>();
         foreach (IReflectField field in aClass.GetDeclaredFields())
         {
             if (!(field is GenericVirtualField))
                 ret.Add(field);
         }
         return ret;
     }
     catch (Exception e)
     {
         LoggingHelper.HandleException(e);
     }
     return null;
 }
Exemplo n.º 17
0
		private void SetFieldsToNull(object @object, IReflectClass claxx)
		{
			IReflectField[] fields;
			fields = claxx.GetDeclaredFields();
			for (int i = 0; i < fields.Length; i++)
			{
				IReflectField field = fields[i];
				if (field.IsStatic())
				{
					continue;
				}
				if (field.IsTransient())
				{
					continue;
				}
				field.Set(@object, null);
			}
			IReflectClass superclass = claxx.GetSuperclass();
			if (superclass == null)
			{
				return;
			}
			SetFieldsToNull(@object, superclass);
		}
Exemplo n.º 18
0
 private IEnumerable<SimpleFieldDescription> ExtractFields(TypeName declaringTypeName, IReflectClass classInfo,
     Func<IReflectClass, ITypeDescription> typeLookUp)
 {
     return classInfo.GetDeclaredFields()
         .Where(f=>!(f is GenericVirtualField))
         .Select(f => CreateField(declaringTypeName, f, typeLookUp));
 }