public void DeserializeFromXml(XmlReader reader, string propertyName) { XmlProxy xmlRoot = XmlProxySerializer.Instance.Deserialize(reader); if (xmlRoot.ElementName == propertyName) { this.Getter = (PropertyAccessModifier)xmlRoot.GetAttr("getter", (int)PropertyAccessModifier.Public); this.Setter = (PropertyAccessModifier)xmlRoot.GetAttr("setter", (int)PropertyAccessModifier.Public); } }
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); }
public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { //ModelElement owner = context.Instance as ModelElement; PropertyAccessModifiers currentObj = (PropertyAccessModifiers)context.PropertyDescriptor.GetValue(context.Instance); PropertyAccessModifier getter = (PropertyAccessModifier)propertyValues["Getter"]; PropertyAccessModifier setter = (PropertyAccessModifier)propertyValues["Setter"]; PropertyAccessModifiers result = new PropertyAccessModifiers { Getter = getter, Setter = setter }; return(result); }
public string ForGetter(IPropertyBase property) { string result = string.Empty; if (this.ActiveDTOStage) { return(result); } PropertyAccessModifier higherModifier = property.PropertyAccess.GetHigherModifier(); if (property.PropertyAccess.Getter != PropertyAccessModifier.Public && property.PropertyAccess.Getter != higherModifier) { result = GetPropertyAccessModifierString(property.PropertyAccess.Getter); } return(result); }
private string GetPropertyAccessModifierString(PropertyAccessModifier modifier) { switch (modifier) { case PropertyAccessModifier.Internal: return(VISIBILITY_INTERNAL); case PropertyAccessModifier.Private: return(VISIBILITY_PRIVATE); case PropertyAccessModifier.Protected: return(VISIBILITY_PROTECTED); case PropertyAccessModifier.ProtectedInternal: return(string.Format("{0} {1}", VISIBILITY_PROTECTED, VISIBILITY_INTERNAL)); } return(string.Empty); }
public string AccessibilityForType(IPropertyBase property) { PropertyAccessModifier accessModifier = PropertyAccessModifier.Public; if (!this.ActiveDTOStage) { accessModifier = property.PropertyAccess.GetHigherModifier(); } string accessibility = accessModifier == PropertyAccessModifier.ProtectedInternal ? VISIBILITY_PROTECTED_INTERNAL : accessModifier.ToString().ToLowerInvariant(); if ((property as IPropertyBase).Owner.TypeKind == PersistentTypeKind.Interface) { accessibility = string.Empty; } return(accessibility); }
private bool PropertyBase_ReadPropertiesFromAttributes(SerializationContext serializationContext, PropertyBase propertyBase, XmlReader reader) { // Access if (!serializationContext.Result.Failed) { string attribAccess = DONetEntityModelDesignerSerializationHelper.Instance.ReadAttribute(serializationContext, propertyBase, reader, "access"); if (attribAccess != null) { AccessModifier valueOfAccess; if (SerializationUtilities.TryGetValue <AccessModifier>(serializationContext, attribAccess, out valueOfAccess)) { propertyBase.PropertyAccess = new PropertyAccessModifiers(); PropertyAccessModifier modifier = valueOfAccess == AccessModifier.Public ? PropertyAccessModifier.Public : PropertyAccessModifier.Internal; propertyBase.PropertyAccess.Getter = modifier; propertyBase.PropertyAccess.Setter = modifier; return(true); } else { // Invalid property value, ignored. EntityModelDesignerSerializationBehaviorSerializationMessages.IgnoredPropertyValue(serializationContext, reader, "access", typeof(AccessModifier), attribAccess); } } else { propertyBase.PropertyAccess = new PropertyAccessModifiers(); propertyBase.PropertyAccess.Getter = PropertyAccessModifier.Public; propertyBase.PropertyAccess.Setter = PropertyAccessModifier.Public; return(false); } } return(false); }
public PropertyAccessModifiers() { this.Getter = PropertyAccessModifier.Public; this.Setter = PropertyAccessModifier.Public; }
public string AccessibilityToString(PropertyAccessModifier propertyAccessModifier) { return(propertyAccessModifier == PropertyAccessModifier.ProtectedInternal ? VISIBILITY_PROTECTED_INTERNAL : propertyAccessModifier.ToString().ToLower()); }