public override void SetValue(object component, object value)
        {
            Activity activity = component as Activity;

            if (activity != null)
            {
                ISite site = PropertyDescriptorUtils.GetSite(ServiceProvider, component);
                if (site == null)
                {
                    throw new Exception(SR.GetString(SR.General_MissingService, typeof(ISite).FullName));
                }

                IIdentifierCreationService identifierCreationService = site.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService;
                if (identifierCreationService == null)
                {
                    throw new Exception(SR.GetString(SR.General_MissingService, typeof(IIdentifierCreationService).FullName));
                }

                string newID = value as string;
                identifierCreationService.ValidateIdentifier(activity, newID);

                DesignerHelpers.UpdateSiteName(activity, newID);
                base.SetValue(component, value);
            }
        }
        public override void SetValue(object component, object value)
        {
            Activity activity = component as Activity;

            if (activity != null)
            {
                IIdentifierCreationService service = activity.Site.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService;
                if (service == null)
                {
                    throw new Exception(SR.GetString("General_MissingService", new object[] { typeof(IIdentifierCreationService).FullName }));
                }
                string identifier = value as string;
                service.ValidateIdentifier(activity, identifier);
                bool ignoreCase      = CompilerHelpers.GetSupportedLanguage(activity.Site) == SupportedLanguages.VB;
                Type dataSourceClass = Helpers.GetDataSourceClass(Helpers.GetRootActivity(activity), activity.Site);
                if ((dataSourceClass != null) && (ActivityBindPropertyDescriptor.FindMatchingMember(identifier, dataSourceClass, ignoreCase) != null))
                {
                    throw new ArgumentException(SR.GetString("Error_ActivityNameExist", new object[] { identifier }));
                }
                IMemberCreationService service2 = activity.Site.GetService(typeof(IMemberCreationService)) as IMemberCreationService;
                if (service2 == null)
                {
                    throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IMemberCreationService).FullName }));
                }
                IDesignerHost host = activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (host == null)
                {
                    throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IDesignerHost).FullName }));
                }
                string newClassName = identifier;
                int    num          = host.RootComponentClassName.LastIndexOf('.');
                if (num > 0)
                {
                    newClassName = host.RootComponentClassName.Substring(0, num + 1) + identifier;
                }
                service2.UpdateTypeName(((Activity)host.RootComponent).GetValue(WorkflowMarkupSerializer.XClassProperty) as string, newClassName);
                ((Activity)host.RootComponent).SetValue(WorkflowMarkupSerializer.XClassProperty, newClassName);
                base.SetValue(component, value);
                DesignerHelpers.UpdateSiteName((Activity)host.RootComponent, identifier);
            }
        }
        public override void SetValue(object component, object value)
        {
            Activity activity = component as Activity;

            if (activity != null)
            {
                // validate the identifier
                IIdentifierCreationService identifierCreationService = activity.Site.GetService(typeof(IIdentifierCreationService)) as IIdentifierCreationService;
                if (identifierCreationService == null)
                {
                    throw new Exception(SR.GetString(SR.General_MissingService, typeof(IIdentifierCreationService).FullName));
                }

                string name = value as string;
                identifierCreationService.ValidateIdentifier(activity, name);

                bool isVB         = (CompilerHelpers.GetSupportedLanguage(activity.Site) == SupportedLanguages.VB);
                Type designedType = Helpers.GetDataSourceClass(Helpers.GetRootActivity(activity), activity.Site);
                if (designedType != null)
                {
                    MemberInfo matchingMember = ActivityBindPropertyDescriptor.FindMatchingMember(name, designedType, isVB);
                    if (matchingMember != null)
                    {
                        throw new ArgumentException(SR.GetString(SR.Error_ActivityNameExist, name));
                    }
                }
                IMemberCreationService memberCreationService = activity.Site.GetService(typeof(IMemberCreationService)) as IMemberCreationService;
                if (memberCreationService == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IMemberCreationService).FullName));
                }

                IDesignerHost host = activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (host == null)
                {
                    throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IDesignerHost).FullName));
                }

                // We need to update the activityType's name before trying to update the type because
                // updating the type causes a flush, which access the custom activity's properties, and
                // doing so requires the new type name
                string newClassName = name;
                int    indexOfDot   = host.RootComponentClassName.LastIndexOf('.');
                if (indexOfDot > 0)
                {
                    newClassName = host.RootComponentClassName.Substring(0, indexOfDot + 1) + name;
                }

                // IMPORTANT: You must update the class name in code before renaming the site, since
                // VS's OnComponentRename updates the RootComponentClassName, so the flush code called
                // in our OnComponentRename tries to access the new class for information.
                memberCreationService.UpdateTypeName(((Activity)host.RootComponent).GetValue(WorkflowMarkupSerializer.XClassProperty) as string, newClassName);

                //((Activity)host.RootComponent).Name = name;
                ((Activity)host.RootComponent).SetValue(WorkflowMarkupSerializer.XClassProperty, newClassName);
                base.SetValue(component, value);

                // Update the site name so the component name shows up correctly in the designer
                DesignerHelpers.UpdateSiteName((Activity)host.RootComponent, name);
            }
        }