public void SetPropAccesses(string[] memberNames, ViewPropertyAccess nLevel) { //! Add access for a list of props in _ObjectInstance. foreach (string memberName in memberNames) { SetPropAccess(memberName, nLevel); } }
public void SetPropAccessAll(ViewPropertyAccess nLevel = ViewPropertyAccess.OptionalEdit) { //! add default access to all props of _ObjectInstance. for simple POCO DTO type objects. //! we can add/remove/change these props later of course. Type oType = _ObjectInstance.GetType(); foreach (var prop in oType.GetProperties()) { SetPropAccess(prop.Name, nLevel); } }
private List <string> _aOrigValues; //! _ObjectInstance.Property.ToString() encoded state of the Props at start/clean state. same enum as _aProps public ViewModelState(object o, bool bTrackChangedValues = true, ViewPropertyAccess nLevelDef = ViewPropertyAccess.Ignored) { _ObjectInstance = o; // ASSUME not null. _aProps = new List <ViewProperty>(); if (bTrackChangedValues) { _aOrigValues = new List <string>(); } else { _aOrigValues = null; // must call UpdateOrigValues() later if i care about tracking changed values. IsChanged() } if (nLevelDef > ViewPropertyAccess.Ignored) { SetPropAccessAll(nLevelDef); } }
public void SetPropAccess(string memberName, ViewPropertyAccess nLevel) { //! What access do we want to give to this sPropName? for current user/form. int i = GetPropIndex(memberName); if (i >= 0) // modify existing? { _aProps[i].Level = nLevel; } else // insert { _aProps.Add(new ViewProperty { MemberName = memberName, Level = nLevel }); if (_aOrigValues != null) { // store current value. _aOrigValues.Add(GetPropValue(memberName)); } } }