private XPMemberInfo CreateMemberInfo(ITypesInfo typesInfo, XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute) {
            var typeToCreateOn = GetTypeToCreateOn(memberInfo, associationAttribute);
            if (typeToCreateOn == null)
                throw new NotImplementedException();
            XPMemberInfo xpCustomMemberInfo;
            if (!(memberInfo.IsCollection) || (memberInfo.IsCollection && providedAssociationAttribute.RelationType == RelationType.ManyToMany)) {
                xpCustomMemberInfo = typesInfo.CreateCollection(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name + "s", false);
            } else {
                xpCustomMemberInfo = typesInfo.CreateMember(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name, false);
            }

            if (!string.IsNullOrEmpty(providedAssociationAttribute.AssociationName) && !memberInfo.HasAttribute(typeof(AssociationAttribute)))
                memberInfo.AddAttribute(new AssociationAttribute(providedAssociationAttribute.AssociationName));

            typesInfo.RefreshInfo(typeToCreateOn);

            return xpCustomMemberInfo;
        }
Beispiel #2
0
 void HideMemberInDetailView(XPMemberInfo xpMemberInfo)
 {
     if (!xpMemberInfo.HasAttribute(typeof(VisibleInDetailViewAttribute)))
     {
         xpMemberInfo.AddAttribute(new VisibleInDetailViewAttribute(false));
     }
 }
Beispiel #3
0
 public static void CreateForeignKey(this ConnectionProviderSql connectionProviderSql, XPMemberInfo xpMemberInfo,
                                     bool throwUnableToCreateDBObjectException = false)
 {
     if (xpMemberInfo.HasAttribute(typeof(AssociationAttribute)))
     {
         CallSchemaUpdateMethod(connectionProviderSql, CreateForeighKey(xpMemberInfo), throwUnableToCreateDBObjectException);
     }
 }
Beispiel #4
0
        public static void ModifyModel(IModelMemberReminderInfo modelMemberReminderInfo, XPMemberInfo customMemberInfo)
        {
            var modelClass = modelMemberReminderInfo.ModelClass;
            var modelClassCreateExpandAbleMembers = modelClass as IModelClassCreateExpandAbleMembers;

            if (modelClassCreateExpandAbleMembers != null)
            {
                modelClassCreateExpandAbleMembers.CreateExpandAbleMembers = true;
            }

            if (!customMemberInfo.HasAttribute(typeof(ExpandObjectMembersAttribute)))
            {
                customMemberInfo.AddAttribute(new ExpandObjectMembersAttribute(ExpandObjectMembers.Always));
            }
        }
Beispiel #5
0
 string TruncateValue(XPMemberInfo xpMemberInfo, string value)
 {
     if (xpMemberInfo.HasAttribute(typeof(SizeAttribute)))
     {
         int size = ((SizeAttribute)xpMemberInfo.GetAttributeInfo(typeof(SizeAttribute))).Size;
         if (size > -1 && value.Length > size)
         {
             value = value.Substring(0, size - 1);
         }
     }
     else if (value.Length > 99)
     {
         value = value.Substring(0, 99);
     }
     return(value);
 }
Beispiel #6
0
 bool MemberHasChanged(ISupportChangedMembers supportChangedMembers, XPMemberInfo m) {
     return m.HasAttribute(typeof(PersistentAttribute)) || m.IsKey || m is ServiceField ||
            supportChangedMembers.ChangedProperties.Contains(m.Name);
 }
Beispiel #7
0
        private XPMemberInfo CreateMemberInfo(ITypesInfo typesInfo, XPMemberInfo memberInfo, ProvidedAssociationAttribute providedAssociationAttribute, AssociationAttribute associationAttribute)
        {
            var typeToCreateOn = GetTypeToCreateOn(memberInfo, associationAttribute);

            if (typeToCreateOn == null)
            {
                throw new NotImplementedException();
            }
            XPMemberInfo xpCustomMemberInfo;

            if (!(memberInfo.IsNonAssociationList) || (memberInfo.IsNonAssociationList && providedAssociationAttribute.RelationType == RelationType.ManyToMany))
            {
                xpCustomMemberInfo = typesInfo.CreateCollection(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name + "s", false);
            }
            else
            {
                xpCustomMemberInfo = typesInfo.CreateMember(
                    typeToCreateOn,
                    memberInfo.Owner.ClassType,
                    associationAttribute.Name,
                    XpandModuleBase.Dictiorary,
                    providedAssociationAttribute.ProvidedPropertyName ?? memberInfo.Owner.ClassType.Name, false);
            }

            if (!string.IsNullOrEmpty(providedAssociationAttribute.AssociationName) && !memberInfo.HasAttribute(typeof(AssociationAttribute)))
            {
                memberInfo.AddAttribute(new AssociationAttribute(providedAssociationAttribute.AssociationName));
            }

            typesInfo.RefreshInfo(typeToCreateOn);

            return(xpCustomMemberInfo);
        }
 void HideMemberInDetailView(XPMemberInfo xpMemberInfo) {
     if (!xpMemberInfo.HasAttribute(typeof(VisibleInDetailViewAttribute)))
         xpMemberInfo.AddAttribute(new VisibleInDetailViewAttribute(false));
 }
Beispiel #9
0
 string TruncateValue(XPMemberInfo xpMemberInfo, string value) {
     if (xpMemberInfo.HasAttribute(typeof(SizeAttribute))) {
         int size = ((SizeAttribute)xpMemberInfo.GetAttributeInfo(typeof(SizeAttribute))).Size;
         if (size > -1 && value.Length > size)
             value = value.Substring(0, size - 1);
     } else if (value.Length > 99)
         value = value.Substring(0, 99);
     return value;
 }
Beispiel #10
0
 public static void CreateForeignKey(this ConnectionProviderSql connectionProviderSql, XPMemberInfo xpMemberInfo,
                                 bool throwUnableToCreateDBObjectException = false) {
     if (xpMemberInfo.HasAttribute(typeof(AssociationAttribute))) {
         CallSchemaUpdateMethod(connectionProviderSql, CreateForeighKey(xpMemberInfo), throwUnableToCreateDBObjectException);
     }
 }
Beispiel #11
0
 bool MemberHasChanged(ISupportChangedMembers supportChangedMembers, XPMemberInfo m)
 {
     return(m.HasAttribute(typeof(PersistentAttribute)) || m.IsKey || m is ServiceField ||
            supportChangedMembers.ChangedProperties.Contains(m.Name));
 }