private void OnRefreshTypes(object sender, EventArgs e) { ITypeProvider typeProvider; if (this.refreshTypesHandler != null) { WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (view != null) { view.Idle -= this.refreshTypesHandler; } this.refreshTypesHandler = null; } IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; Activity seedActivity = (host != null) ? (host.RootComponent as Activity) : null; if (seedActivity != null) { typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) { Walker walker = new Walker(); walker.FoundProperty += delegate (Walker w, WalkerEventArgs args) { if (((args.CurrentValue != null) && (args.CurrentProperty != null)) && ((args.CurrentProperty.PropertyType == typeof(Type)) && (args.CurrentValue is Type))) { Type type = typeProvider.GetType(((Type) args.CurrentValue).FullName); if (type != null) { args.CurrentProperty.SetValue(args.CurrentPropertyOwner, type, null); if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); } } } else if (((args.CurrentProperty == null) && (args.CurrentValue is DependencyObject)) && !(args.CurrentValue is Activity)) { walker.WalkProperties(args.CurrentActivity, args.CurrentValue); } }; walker.FoundActivity += delegate (Walker w, WalkerEventArgs args) { if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); ActivityDesigner designer = ActivityDesigner.GetDesigner(args.CurrentActivity); if (designer != null) { designer.RefreshDesignerActions(); } InvokeWorkflowDesigner designer2 = designer as InvokeWorkflowDesigner; if (designer2 != null) { designer2.RefreshTargetWorkflowType(); } } }; walker.Walk(seedActivity); } IPropertyValueUIService service = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service != null) { service.NotifyPropertyValueUIItemsChanged(); } this.RefreshTasks(); this.RefreshDesignerActions(); } }
public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj) { if (manager == null) { throw new ArgumentNullException("manager"); } if (obj == null) { throw new ArgumentNullException("obj"); } ValidationErrorCollection errors = new ValidationErrorCollection(); Activity activity = manager.Context[typeof(Activity)] as Activity; Walker walker = new Walker(true); walker.FoundProperty += delegate (Walker w, WalkerEventArgs args) { if ((args.CurrentProperty != null) && (DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType) == null)) { object[] customAttributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true); if (((customAttributes.Length > 0) ? ((ValidationOptionAttribute) customAttributes[0]).ValidationOption : ValidationOption.Optional) != ValidationOption.None) { errors.AddRange(this.ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager)); args.Action = WalkerAction.Skip; } } }; walker.WalkProperties(activity, obj); return errors; }