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())); }
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; } } } } }
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; } } } } }
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]; } }
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())); }