示例#1
0
    public string ForSetter(IPropertyBase property, IPropertiesBuilder propertiesBuilder)
    {
        string result = string.Empty;

        if (this.ActiveDTOStage)
        {
            return(result);
        }

        switch (property.PropertyKind)
        {
        case PropertyKind.Scalar:
        {
            IOrmAttribute[] typeAttributes = propertiesBuilder.GetPropertyTypeAttributes(property);
            OrmKeyAttribute keyAttribute   = (OrmKeyAttribute)typeAttributes.Single(item => item is OrmKeyAttribute);

            result = keyAttribute.Enabled ? VISIBILITY_PRIVATE : string.Empty;
            break;
        }

        case PropertyKind.Navigation:
        {
            IOrmAttribute[] typeAttributes = propertiesBuilder.GetPropertyTypeAttributes(property);
            OrmKeyAttribute keyAttribute   = (OrmKeyAttribute)typeAttributes.Single(item => item is OrmKeyAttribute);

            INavigationProperty navigationProperty = (INavigationProperty)property;
            if (navigationProperty.Multiplicity == MultiplicityKind.Many || keyAttribute.Enabled)
            {
                result = VISIBILITY_PRIVATE;
            }

            break;
        }
        }

        // only when result is not directly 'private' because of business rules we can adjust it from settings
        if (string.IsNullOrEmpty(result))
        {
            PropertyAccessModifier higherModifier = property.PropertyAccess.GetHigherModifier();

            if (property.PropertyAccess.Setter != PropertyAccessModifier.Public && property.PropertyAccess.Setter != higherModifier)
            {
                result = GetPropertyAccessModifierString(property.PropertyAccess.Setter);
            }
        }

        return(result);
    }
示例#2
0
    public string[] CreateTypeAttributes(IPropertyBase property, IPropertiesBuilder propertiesBuilder)
    {
        if (this.ActiveDTOStage)
        {
            return(new string[0]);
        }

        IEnumerable <IOrmAttribute> typeAttributes = null;

        if (propertiesBuilder != null)
        {
            typeAttributes = propertiesBuilder.GetPropertyTypeAttributes(property);

            property = propertiesBuilder.GetProperty(property, InheritanceMember.Inherited);
        }

        if (typeAttributes == null)
        {
            typeAttributes = property.TypeAttributes;
        }

        ITypeAttributesBuilder attributesBuilder = TypeAttributesBuilder.Create(property, typeAttributes);

        return(CreateTypeAttributes(attributesBuilder, typeAttributes));
    }