コード例 #1
0
        /// <summary>See <see cref="ElementTypeDescriptor.ShouldCreatePropertyDescriptor"/>.</summary>
        protected override bool ShouldCreatePropertyDescriptor(ModelElement requestor, DomainPropertyInfo domainProperty)
        {
            Guid propertyId = domainProperty.Id;

            if (propertyId == Role.MultiplicityDomainPropertyId)
            {
                FactType        factType = ModelElement.FactType;
                Objectification objectification;
                LinkedElementCollection <RoleBase> roles;
                // Display for binary fact types
                if (factType != null &&
                    !(factType is QueryBase) &&
                    (roles = factType.RoleCollection).Count == 2)
                {
                    if (null != (objectification = factType.ImpliedByObjectification))
                    {
                        roles = objectification.NestedFactType.RoleCollection;
                        if (roles.Count != 2)
                        {
                            return(false);
                        }
                    }
                    return(!FactType.GetUnaryRoleIndex(roles).HasValue);
                }
                return(false);
            }
            else if (propertyId == Role.IsMandatoryDomainPropertyId ||
                     propertyId == Role.ValueRangeTextDomainPropertyId)
            {
                if (ModelElement.FactType is QueryBase)
                {
                    return(false);
                }
            }
            else if (propertyId == Role.MandatoryConstraintNameDomainPropertyId ||
                     propertyId == Role.MandatoryConstraintModalityDomainPropertyId)
            {
                return(ModelElement.SimpleMandatoryConstraint != null);
            }
            else if (propertyId == Role.ObjectificationOppositeRoleNameDomainPropertyId)
            {
                FactType fact = ModelElement.FactType;
                return(fact != null && fact.Objectification != null);
            }
            return(base.ShouldCreatePropertyDescriptor(requestor, domainProperty));
        }