internal static PropertyDescriptorCollection GetPropertiesForEvents(IServiceProvider serviceProvider, object eventOwner) { List <PropertyDescriptor> list = new List <PropertyDescriptor>(); IEventBindingService service = serviceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService; if (service != null) { foreach (EventDescriptor descriptor in TypeDescriptor.GetEvents(eventOwner)) { if (descriptor.IsBrowsable) { PropertyDescriptor eventProperty = service.GetEventProperty(descriptor); if (!(eventProperty is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(eventProperty)) { list.Add(new ActivityBindPropertyDescriptor(serviceProvider, eventProperty, eventOwner)); } else { list.Add(eventProperty); } } } } return(new PropertyDescriptorCollection(list.ToArray())); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } this.serviceProvider = serviceProvider; object returnValue = value; if (context != null && context.PropertyDescriptor is DynamicPropertyDescriptor) { try { using (ActivityBindForm bindDialog = new ActivityBindForm(this.serviceProvider, context)) { if (DialogResult.OK == bindDialog.ShowDialog()) { //Now that OK has been pressed in the dialog we need to create members if necessary if (bindDialog.CreateNew) { //Emit the field / property as required if (bindDialog.CreateNewProperty) { List <CustomProperty> properties = CustomActivityDesignerHelper.GetCustomProperties(context); if (properties != null) { properties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, bindDialog.NewMemberName, context.PropertyDescriptor, context.Instance)); CustomActivityDesignerHelper.SetCustomProperties(properties, context); } } else { ActivityBindPropertyDescriptor.CreateField(context, bindDialog.Binding, true); } } returnValue = bindDialog.Binding; } } } catch (Exception e) { string message = SR.GetString(SR.Error_CanNotBindProperty, context.PropertyDescriptor.Name); if (!String.IsNullOrEmpty(e.Message)) { message += "\n\n" + e.Message; } DesignerHelpers.ShowError(context, message); } } else { DesignerHelpers.ShowError(this.serviceProvider, SR.GetString(SR.Error_MultipleSelectNotSupportedForBindAndPromote)); } return(returnValue); }
private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList) { IComponent component = null; IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService; if (referenceService != null) { component = referenceService.GetComponent(context.Instance); } string fullAliasName = string.Empty; //this attribue is set to overcome issue with the TypedVariableDeclarationTypeConverter //not returning Name property at all. we alias that property to the VariableDeclaration itself DefaultPropertyAttribute aliasPropertyNameAttribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute; if (aliasPropertyNameAttribute != null && aliasPropertyNameAttribute.Name != null && aliasPropertyNameAttribute.Name.Length > 0) { fullAliasName = propDesc.Name + "." + aliasPropertyNameAttribute.Name; } if (component != null) { ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(component as Activity); if (activityDesigner != null) { if (!activityDesigner.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc) && !propDesc.IsReadOnly) { valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage(DR.Bind), OnBindProperty, DR.GetString(DR.BindProperty))); } string fullComponentName = referenceService.GetName(component); //schedule1.send1 string fullPropertyName = referenceService.GetName(context.Instance); //schedule1.send1.message fullPropertyName = (fullPropertyName.Length > fullComponentName.Length) ? fullPropertyName.Substring(fullComponentName.Length + 1, fullPropertyName.Length - fullComponentName.Length - 1) + "." + propDesc.Name : string.Empty; foreach (DesignerAction action in activityDesigner.DesignerActions) { string actionPropertyName = action.PropertyName as string; if (actionPropertyName == null || actionPropertyName.Length == 0) { continue; } if (actionPropertyName == propDesc.Name || (actionPropertyName == fullPropertyName) || (actionPropertyName == fullAliasName)) { PropertyValueUIItemHandler propValueUIItemhandler = new PropertyValueUIItemHandler(action); valueUIItemList.Add(new PropertyValueUIItem(action.Image, propValueUIItemhandler.OnFixPropertyError, action.Text)); break; } } } } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider serviceProvider, object value) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } this.serviceProvider = serviceProvider; object obj2 = value; if ((context != null) && (context.PropertyDescriptor is DynamicPropertyDescriptor)) { try { using (ActivityBindForm form = new ActivityBindForm(this.serviceProvider, context)) { if (DialogResult.OK != form.ShowDialog()) { return(obj2); } if (form.CreateNew) { if (form.CreateNewProperty) { List <CustomProperty> customProperties = CustomActivityDesignerHelper.GetCustomProperties(context); if (customProperties != null) { customProperties.Add(CustomProperty.CreateCustomProperty(this.serviceProvider, form.NewMemberName, context.PropertyDescriptor, context.Instance)); CustomActivityDesignerHelper.SetCustomProperties(customProperties, context); } } else { ActivityBindPropertyDescriptor.CreateField(context, form.Binding, true); } } return(form.Binding); } } catch (Exception exception) { string message = SR.GetString("Error_CanNotBindProperty", new object[] { context.PropertyDescriptor.Name }); if (!string.IsNullOrEmpty(exception.Message)) { message = message + "\n\n" + exception.Message; } DesignerHelpers.ShowError(context, message); } return(obj2); } DesignerHelpers.ShowError(this.serviceProvider, SR.GetString("Error_MultipleSelectNotSupportedForBindAndPromote")); return(obj2); }
private void GetActualTypeConverterAndContext(ITypeDescriptorContext currentContext, out TypeConverter realTypeConverter, out ITypeDescriptorContext realContext) { realContext = currentContext; realTypeConverter = null; if ((currentContext != null) && (currentContext.PropertyDescriptor != null)) { realTypeConverter = TypeDescriptor.GetConverter(currentContext.PropertyDescriptor.PropertyType); ActivityBindPropertyDescriptor propertyDescriptor = currentContext.PropertyDescriptor as ActivityBindPropertyDescriptor; if (((propertyDescriptor != null) && (propertyDescriptor.RealPropertyDescriptor != null)) && ((propertyDescriptor.RealPropertyDescriptor.Converter != null) && (propertyDescriptor.RealPropertyDescriptor.Converter.GetType() != typeof(ActivityBindTypeConverter)))) { realTypeConverter = propertyDescriptor.RealPropertyDescriptor.Converter; realContext = new TypeDescriptorContext(currentContext, propertyDescriptor.RealPropertyDescriptor, currentContext.Instance); } } }
private static void InternalFilterProperties(IServiceProvider serviceProvider, object propertyOwner, IDictionary properties) { // change property descriptors Hashtable newProperties = new Hashtable(); foreach (object key in properties.Keys) { PropertyDescriptor propDesc = properties[key] as PropertyDescriptor; if (string.Equals(propDesc.Name, "Name", StringComparison.Ordinal) && typeof(Activity).IsAssignableFrom(propDesc.ComponentType)) { //Activity id Activity activity = propertyOwner as Activity; if (activity != null && activity == Helpers.GetRootActivity(activity)) { newProperties[key] = new NamePropertyDescriptor(serviceProvider, propDesc); } else { newProperties[key] = new IDPropertyDescriptor(serviceProvider, propDesc); } } else if (!(propDesc is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) { if (typeof(Type).IsAssignableFrom(propDesc.PropertyType) && !(propDesc is ParameterInfoBasedPropertyDescriptor)) { propDesc = new TypePropertyDescriptor(serviceProvider, propDesc); } newProperties[key] = new ActivityBindPropertyDescriptor(serviceProvider, propDesc, propertyOwner); } else if (typeof(Type).IsAssignableFrom(propDesc.PropertyType)) { newProperties[key] = new TypePropertyDescriptor(serviceProvider, propDesc); } else { newProperties[key] = new DynamicPropertyDescriptor(serviceProvider, propDesc); } } foreach (object key in newProperties.Keys) { properties[key] = newProperties[key]; } }
private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList) { IComponent reference = null; IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService; if (service != null) { reference = service.GetComponent(context.Instance); } string str = string.Empty; DefaultPropertyAttribute attribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute; if (((attribute != null) && (attribute.Name != null)) && (attribute.Name.Length > 0)) { str = propDesc.Name + "." + attribute.Name; } if (reference != null) { ActivityDesigner designer = ActivityDesigner.GetDesigner(reference as Activity); if (designer != null) { if ((!designer.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) && !propDesc.IsReadOnly) { valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage("Bind"), new PropertyValueUIItemInvokeHandler(this.OnBindProperty), DR.GetString("BindProperty", new object[0]))); } string name = service.GetName(reference); string str3 = service.GetName(context.Instance); str3 = (str3.Length > name.Length) ? (str3.Substring(name.Length + 1, (str3.Length - name.Length) - 1) + "." + propDesc.Name) : string.Empty; foreach (DesignerAction action in designer.DesignerActions) { string propertyName = action.PropertyName; if (((propertyName != null) && (propertyName.Length != 0)) && (((propertyName == propDesc.Name) || (propertyName == str3)) || (propertyName == str))) { PropertyValueUIItemHandler handler = new PropertyValueUIItemHandler(action); valueUIItemList.Add(new PropertyValueUIItem(action.Image, new PropertyValueUIItemInvokeHandler(handler.OnFixPropertyError), action.Text)); break; } } } } }
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); } }
private static void InternalFilterProperties(IServiceProvider serviceProvider, object propertyOwner, IDictionary properties) { Hashtable hashtable = new Hashtable(); foreach (object obj2 in properties.Keys) { PropertyDescriptor actualPropDesc = properties[obj2] as PropertyDescriptor; if (string.Equals(actualPropDesc.Name, "Name", StringComparison.Ordinal) && typeof(Activity).IsAssignableFrom(actualPropDesc.ComponentType)) { Activity activity = propertyOwner as Activity; if ((activity != null) && (activity == Helpers.GetRootActivity(activity))) { hashtable[obj2] = new NamePropertyDescriptor(serviceProvider, actualPropDesc); } else { hashtable[obj2] = new IDPropertyDescriptor(serviceProvider, actualPropDesc); } } else if (!(actualPropDesc is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(actualPropDesc)) { if (typeof(Type).IsAssignableFrom(actualPropDesc.PropertyType) && !(actualPropDesc is ParameterInfoBasedPropertyDescriptor)) { actualPropDesc = new TypePropertyDescriptor(serviceProvider, actualPropDesc); } hashtable[obj2] = new ActivityBindPropertyDescriptor(serviceProvider, actualPropDesc, propertyOwner); } else if (typeof(Type).IsAssignableFrom(actualPropDesc.PropertyType)) { hashtable[obj2] = new TypePropertyDescriptor(serviceProvider, actualPropDesc); } else { hashtable[obj2] = new DynamicPropertyDescriptor(serviceProvider, actualPropDesc); } } foreach (object obj3 in hashtable.Keys) { properties[obj3] = hashtable[obj3]; } }
private void GetActualTypeConverterAndContext(ITypeDescriptorContext currentContext, out TypeConverter realTypeConverter, out ITypeDescriptorContext realContext) { //The following case covers the scenario where we have users writting custom property descriptors in which they have returned custom type converters //In such cases we should honor the type converter returned by property descriptor only if it is not a ActivityBindTypeConverter //If it is ActivityBindTypeConveter then we should lookup the converter based on Property type //Please be care ful when you change this code as it will break ParameterInfoBasedPropertyDescriptor realContext = currentContext; realTypeConverter = null; if (currentContext != null && currentContext.PropertyDescriptor != null) { realTypeConverter = TypeDescriptor.GetConverter(currentContext.PropertyDescriptor.PropertyType); ActivityBindPropertyDescriptor activityBindPropertyDescriptor = currentContext.PropertyDescriptor as ActivityBindPropertyDescriptor; if (activityBindPropertyDescriptor != null && activityBindPropertyDescriptor.RealPropertyDescriptor != null && activityBindPropertyDescriptor.RealPropertyDescriptor.Converter != null && activityBindPropertyDescriptor.RealPropertyDescriptor.Converter.GetType() != typeof(ActivityBindTypeConverter)) { realTypeConverter = activityBindPropertyDescriptor.RealPropertyDescriptor.Converter; realContext = new TypeDescriptorContext(currentContext, activityBindPropertyDescriptor.RealPropertyDescriptor, currentContext.Instance); } } }
private static void InternalFilterProperties(IServiceProvider serviceProvider, object propertyOwner, IDictionary properties) { // change property descriptors Hashtable newProperties = new Hashtable(); foreach (object key in properties.Keys) { PropertyDescriptor propDesc = properties[key] as PropertyDescriptor; if (string.Equals(propDesc.Name, "Name", StringComparison.Ordinal) && typeof(Activity).IsAssignableFrom(propDesc.ComponentType)) { //Activity id Activity activity = propertyOwner as Activity; if (activity != null && activity == Helpers.GetRootActivity(activity)) newProperties[key] = new NamePropertyDescriptor(serviceProvider, propDesc); else newProperties[key] = new IDPropertyDescriptor(serviceProvider, propDesc); } else if (!(propDesc is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) { if (typeof(Type).IsAssignableFrom(propDesc.PropertyType) && !(propDesc is ParameterInfoBasedPropertyDescriptor)) propDesc = new TypePropertyDescriptor(serviceProvider, propDesc); newProperties[key] = new ActivityBindPropertyDescriptor(serviceProvider, propDesc, propertyOwner); } else if (typeof(Type).IsAssignableFrom(propDesc.PropertyType)) { newProperties[key] = new TypePropertyDescriptor(serviceProvider, propDesc); } else { newProperties[key] = new DynamicPropertyDescriptor(serviceProvider, propDesc); } } foreach (object key in newProperties.Keys) { properties[key] = newProperties[key]; } }
private static void InternalFilterProperties(IServiceProvider serviceProvider, object propertyOwner, IDictionary properties) { Hashtable hashtable = new Hashtable(); foreach (object obj2 in properties.Keys) { PropertyDescriptor actualPropDesc = properties[obj2] as PropertyDescriptor; if (string.Equals(actualPropDesc.Name, "Name", StringComparison.Ordinal) && typeof(Activity).IsAssignableFrom(actualPropDesc.ComponentType)) { Activity activity = propertyOwner as Activity; if ((activity != null) && (activity == Helpers.GetRootActivity(activity))) { hashtable[obj2] = new NamePropertyDescriptor(serviceProvider, actualPropDesc); } else { hashtable[obj2] = new IDPropertyDescriptor(serviceProvider, actualPropDesc); } } else if (!(actualPropDesc is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(actualPropDesc)) { if (typeof(Type).IsAssignableFrom(actualPropDesc.PropertyType) && !(actualPropDesc is ParameterInfoBasedPropertyDescriptor)) { actualPropDesc = new TypePropertyDescriptor(serviceProvider, actualPropDesc); } hashtable[obj2] = new ActivityBindPropertyDescriptor(serviceProvider, actualPropDesc, propertyOwner); } else if (typeof(Type).IsAssignableFrom(actualPropDesc.PropertyType)) { hashtable[obj2] = new TypePropertyDescriptor(serviceProvider, actualPropDesc); } else { hashtable[obj2] = new DynamicPropertyDescriptor(serviceProvider, actualPropDesc); } } foreach (object obj3 in hashtable.Keys) { properties[obj3] = hashtable[obj3]; } }
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); } }
internal static bool CreateField(ITypeDescriptorContext context, ActivityBind activityBind, bool throwOnError) { //Check if the activity is root activity and has valid design time type if (!String.IsNullOrEmpty(activityBind.Path)) { Type boundType = PropertyDescriptorUtils.GetBaseType(context.PropertyDescriptor, context.Instance, context); Activity activity = PropertyDescriptorUtils.GetComponent(context) as Activity; if (activity != null && boundType != null) { activity = Helpers.ParseActivityForBind(activity, activityBind.Name); if (activity == Helpers.GetRootActivity(activity)) { bool isVB = (CompilerHelpers.GetSupportedLanguage(context) == SupportedLanguages.VB); Type designedType = Helpers.GetDataSourceClass(activity, context); if (designedType != null) { //field path could be nested too. //need to find field only with the name up to the first dot (CimplexTypeField in the example below) //and the right type (that would be tricky if the field doesnt exist yet) //example: CimplexTypeField.myIDictionary_int_string[10].someOtherGood2 string fieldName = activityBind.Path; int indexOfDot = fieldName.IndexOfAny(new char[] { '.', '/', '[' }); if (indexOfDot != -1) { fieldName = fieldName.Substring(0, indexOfDot); //path is a nested field access } MemberInfo matchingMember = ActivityBindPropertyDescriptor.FindMatchingMember(fieldName, designedType, isVB); if (matchingMember != null) { Type memberType = null; bool isPrivate = false; if (matchingMember is FieldInfo) { isPrivate = ((FieldInfo)matchingMember).IsPrivate; memberType = ((FieldInfo)matchingMember).FieldType; } else if (matchingMember is PropertyInfo) { MethodInfo getMethod = ((PropertyInfo)matchingMember).GetGetMethod(); MethodInfo setMethod = ((PropertyInfo)matchingMember).GetSetMethod(); isPrivate = ((getMethod != null && getMethod.IsPrivate) || (setMethod != null && setMethod.IsPrivate)); } else if (matchingMember is MethodInfo) { isPrivate = ((MethodInfo)matchingMember).IsPrivate; } if (indexOfDot != -1) { //need to find the type of the member the path references (and if the path is valid at all) PathWalker pathWalker = new PathWalker(); PathMemberInfoEventArgs finalEventArgs = null; pathWalker.MemberFound += delegate(object sender, PathMemberInfoEventArgs eventArgs) { finalEventArgs = eventArgs; }; if (pathWalker.TryWalkPropertyPath(designedType, activityBind.Path)) { //successfully walked the entire path memberType = BindHelpers.GetMemberType(finalEventArgs.MemberInfo); } else { //the path is invalid if (throwOnError) { throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName)); } return(false); } } if ((matchingMember.DeclaringType == designedType || !isPrivate) && matchingMember is FieldInfo && TypeProvider.IsAssignable(boundType, memberType)) { return(true); } else { if (throwOnError) { throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName)); } return(false); } } else { // Find out if the name conflicts with an existing activity that has not be flushed in to the // code beside. An activity bind can bind to this field only if the type of the property // is the assignable from the activity type. Activity matchingActivity = null; if (string.Compare(activity.Name, fieldName, isVB ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0) { matchingActivity = activity; } else if (activity is CompositeActivity) { if (activity is CompositeActivity) { foreach (Activity existingActivity in Helpers.GetAllNestedActivities(activity as CompositeActivity)) { if (string.Compare(existingActivity.Name, fieldName, isVB ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) == 0) { matchingActivity = existingActivity; } } } } if (matchingActivity != null) { if (TypeProvider.IsAssignable(boundType, matchingActivity.GetType())) { return(true); } else { if (throwOnError) { throw new InvalidOperationException(SR.GetString(SR.Error_MemberWithSameNameExists, activityBind.Path, designedType.FullName)); } return(false); } } } IMemberCreationService memberCreationService = context.GetService(typeof(IMemberCreationService)) as IMemberCreationService; if (memberCreationService == null) { if (throwOnError) { throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IMemberCreationService).FullName)); } } else { IDesignerHost designerHost = context.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost == null) { if (throwOnError) { throw new InvalidOperationException(SR.GetString("General_MissingService", typeof(IDesignerHost).FullName)); } } else { memberCreationService.CreateField(designerHost.RootComponentClassName, activityBind.Path, boundType, null, MemberAttributes.Public, null, false); return(true); } } } } } else { if (activity == null && throwOnError) { throw new InvalidOperationException(SR.GetString(SR.Error_InvalidActivityIdentifier, activityBind.Name)); } if (boundType == null && throwOnError) { throw new InvalidOperationException(SR.GetString(SR.Error_PropertyTypeNotDefined, context.PropertyDescriptor.Name, typeof(ActivityBind).Name, typeof(IDynamicPropertyTypeProvider).Name)); } } } return(false); }
internal static PropertyDescriptorCollection GetPropertiesForEvents(IServiceProvider serviceProvider, object eventOwner) { //Now for each event we need to add properties List <PropertyDescriptor> properties = new List <PropertyDescriptor>(); // Find out if there is a data context. IEventBindingService eventBindingService = serviceProvider.GetService(typeof(IEventBindingService)) as IEventBindingService; if (eventBindingService != null) { foreach (EventDescriptor eventDesc in TypeDescriptor.GetEvents(eventOwner)) { if (eventDesc.IsBrowsable) { PropertyDescriptor propertyDescriptor = eventBindingService.GetEventProperty(eventDesc); if (!(propertyDescriptor is ActivityBindPropertyDescriptor) && ActivityBindPropertyDescriptor.IsBindableProperty(propertyDescriptor)) { properties.Add(new ActivityBindPropertyDescriptor(serviceProvider, propertyDescriptor, eventOwner)); } else { properties.Add(propertyDescriptor); } } } } return(new PropertyDescriptorCollection(properties.ToArray())); }