I have a property created like this in a BusinessBase class:
private static PropertyInfo<string> ABCProperty = RegisterProperty(typeof(ObjectA), new PropertyInfo<string>("ABC"));
public string ABC
{
get { return GetProperty(ABCProperty); }
internal set { SetProperty(ABCProperty, value); }
}
The above makes the property to be read-only in a form (cannot be changed by a user).
Is it possible, based on some global setting's value that I'd like to define in my application, to make this property writable? With other words, ABCProperty's value could be changed by a user, if setting's variable is True, otherwise this property should remain read-only. If it is not possible, what would be other alternative way to achieve this?
Thank you kindly,
Tanja.
Hi,
The recommended solution is to use AuthorizationRules to determine wheter a user has acces to Read/Write property value. CSLA comes with standard authorization rules for IsInRole and IsNotInRole but you can easily create yourown rules and test whichever way YOU want to dermine whether user is allowed access or not.
Another possible alternative is to override CanWriteProperty and check whether a "global" flag is set or not.
Thank you, JonnyBee. That did the trick.
Typically we would use canwriteproperty and return a true or false based on whether the current user, as identified by their role permissions .. should be able to edit the value.
Copyright (c) Marimer LLC