Exemplo n.º 1
0
        public void UpdateAssociation()
        {
            if (typeof(PersistentObject).IsAssignableFrom(OriginalField.PropertyType) || IsList)
            {
                string name = null;

                if (OriginalField.HasCustomAttribute <AssociationAttribute>())
                {
                    name = OriginalField.GetCustomAttribute <AssociationAttribute>().Name;
                }

                ClassWrapper foreignClassWrapper;

                if (!IsList)
                {
                    //foreignClassWrapper = wrappingHandler
                    //.getClassWrapper((Class <? extends PersistentObject >) fieldToWrap.getType
                    foreignClassWrapper = WrappingHandler.GetClassWrapper(OriginalField.PropertyType);
                }
                else
                {
                    // find generic parameter
                    var foreignClass = OriginalField.PropertyType.GetGenericArguments()[0];

                    // find classWrapper
                    foreignClassWrapper = WrappingHandler.GetClassWrapper(foreignClass);
                }

                Association = new AssociationWrapper(foreignClassWrapper, name);
            }
        }
Exemplo n.º 2
0
 public PropertyWrapper(ClassWrapper cw, PropertyInfo field, WrappingHandler handler)
 {
     WrappingHandler       = handler;
     OriginalField         = field;
     Name                  = CalculateFieldName(field);
     Size                  = field.HasCustomAttribute <SizeAttribute>() ? field.GetCustomAttribute <SizeAttribute>().Length : -1;
     DBType                = handler.PropertyTypeParser.ParseFieldType(field.PropertyType, Size);
     IsPrimaryKey          = field.HasCustomAttribute <PrimaryKeyAttribute>();
     CanNotBeNull          = field.HasCustomAttribute <CanNotBeNullAttribute>();
     Autoincrement         = field.HasCustomAttribute <AutoincrementAttribute>();
     IsList                = typeof(GenericList).IsAssignableFrom(field.PropertyType);
     DeclaringClassWrapper = cw;
     Association           = null;
 }