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();
            }
        }
        private void OnRefreshTypes(object sender, EventArgs e)
        {
            if (this.refreshTypesHandler != null)
            {
                WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
                if (workflowView != null)
                {
                    workflowView.Idle -= this.refreshTypesHandler;
                }
                this.refreshTypesHandler = null;
            }

            IDesignerHost designerHost = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
            Activity      rootActivity = (designerHost != null) ? designerHost.RootComponent as Activity : null;

            if (rootActivity == null)
            {
                return;
            }

            //Now Refresh the types as well as the designer actions
            ITypeProvider 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(System.Type) &&
                        args.CurrentValue is System.Type)
                    {
                        Type updatedType = typeProvider.GetType(((Type)args.CurrentValue).FullName);
                        if (updatedType != null)
                        {
                            args.CurrentProperty.SetValue(args.CurrentPropertyOwner, updatedType, 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 activityDesigner = ActivityDesigner.GetDesigner(args.CurrentActivity);
                        if (activityDesigner != null)
                        {
                            activityDesigner.RefreshDesignerActions();
                        }

                        InvokeWorkflowDesigner invokeWorkflowDesigner = activityDesigner as InvokeWorkflowDesigner;
                        if (invokeWorkflowDesigner != null)
                        {
                            invokeWorkflowDesigner.RefreshTargetWorkflowType();
                        }
                    }
                };

                walker.Walk(rootActivity);
            }

            IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService;

            if (propertyValueService != null)
            {
                propertyValueService.NotifyPropertyValueUIItemsChanged();
            }

            RefreshTasks();
            RefreshDesignerActions();
        }