private void EndModelChange() { ValidationService validationService = this.modelTreeManager.Context.Services.GetService <ValidationService>(); if (validationService != null) { validationService.ActivateValidation(); } }
public bool TryReplaceArgument(ModelTreeManager modelTreeManager, ValidationService validationService) { Fx.Assert(modelTreeManager != null, "modelTreeManager cannot be null."); Fx.Assert(validationService != null, "validationService cannot be null."); ModelItem expressionModelItem = modelTreeManager.GetModelItem(this.ExpressionToReplace); if (expressionModelItem != null) { ModelItem argumentModelItem = expressionModelItem.Parent; ModelItem parentObject = argumentModelItem.Parent; if (argumentModelItem.Source != null) { ModelProperty argumentProperty = parentObject.Properties[argumentModelItem.Source.Name]; Type argumentPropertyType = argumentProperty.PropertyType; if (argumentPropertyType == typeof(InArgument) || argumentPropertyType == typeof(OutArgument) || argumentPropertyType == typeof(InOutArgument)) { ModelItem oldArgumentModel = argumentProperty.Value; ModelItem newArgumentModel = argumentProperty.SetValue(this.NewArgument); // Make sure argument.Expression is wrapped in ModelItem as well ModelItem newExpressionModel = newArgumentModel.Properties["Expression"].Value; return(true); } } } else { Activity parentActivity = ValidationService.GetParent(this.ExpressionToReplace); if (this.ArgumentAccessor.Setter != null) { try { validationService.DeactivateValidation(); this.ArgumentAccessor.Setter(parentActivity, this.NewArgument); return(true); } finally { validationService.ActivateValidation(); } } } return(false); }