public static PropertyDescriptorCollection GetProperties(Type memberType) { if (memberType == null) return PropertyDescriptorCollection.Empty; PropertyDescriptorCollection pdc; if ((pdc = (PropertyDescriptorCollection) collections[memberType]) != null) return (pdc); PropertyInfo[] allProps = memberType.GetProperties(); int l = allProps.Length; for (int i = 0; i < allProps.Length; i++) { PropertyInfo pi = allProps[i]; if (!IsAllowedProperty(pi.Name)) { allProps[i] = null; l--; } } PropertyDescriptor[] descriptors = new PropertyDescriptor[l]; int j = 0; foreach(PropertyInfo pinfo in allProps) { if (pinfo != null) { descriptors[j++] = new ExtendedPropertyDescriptor(pinfo.Name, memberType, pinfo.PropertyType); } } PropertyDescriptorCollection result = new PropertyDescriptorCollection(descriptors); collections.Add(memberType, result); return result; }
protected override object SelectedValue(object value, ITypeDescriptorContext context) { Dictionary <string, string> actionDictionaryList = new Dictionary <string, string>(); actionDictionaryList.Add("Read from Http Header", "HttpHeader"); actionDictionaryList.Add("Read from XPath", "XPath"); actionDictionaryList.Add("Read from Message Context", "MessageContext"); actionDictionaryList.Add("Read Constant", "Constant"); actionDictionaryList.Add("Read BizTalk Macros", "BizTalkMacros"); actionDictionaryList.Add("Write to Http Header", "HttpHeader"); actionDictionaryList.Add("Write to XPath", "XPath"); actionDictionaryList.Add("Write to Message Context", "MessageContext"); actionDictionaryList.Add("Write to Message Context & Promote", "PromoteMessageContext"); actionDictionaryList.Add("Alter Xml Structure", "XmlStructure"); actionDictionaryList.Add("None", "None"); object selectedValue = base.SelectedValue(value, context); ExtendedPropertyDescriptor propertyDescriptor = context.PropertyDescriptor as ExtendedPropertyDescriptor; if (propertyDescriptor.Name.Equals("ReadFrom", System.StringComparison.OrdinalIgnoreCase)) { EditorUtility.SetOutputProperty <string>(context, "ReadItem", string.Empty); } if (propertyDescriptor.Name.Equals("WriteTo", System.StringComparison.OrdinalIgnoreCase)) { EditorUtility.SetOutputProperty <string>(context, "WriteItem", string.Empty); } return(actionDictionaryList[selectedValue.ToString()]); }
protected override object FillProperties(ITypeDescriptorContext context, object value) { ExtendedPropertyDescriptor propertyDescriptor = context.PropertyDescriptor as ExtendedPropertyDescriptor; string readOrWriteAction = string.Empty; if (propertyDescriptor.Name.Equals("ReadItem", System.StringComparison.OrdinalIgnoreCase)) { readOrWriteAction = EditorUtility.GetInputProperty <string>(context, "ReadFrom"); Guard.ArgumentNotNullOrEmpty(readOrWriteAction, "Read Action"); } if (propertyDescriptor.Name.Equals("WriteItem", System.StringComparison.OrdinalIgnoreCase)) { readOrWriteAction = EditorUtility.GetInputProperty <string>(context, "WriteTo"); Guard.ArgumentNotNullOrEmpty(readOrWriteAction, "Write Action"); } if (readOrWriteAction.Equals("HttpHeader")) { return(Initialize(typeof(HttpHeaderEditor), value.ToString())); } else if (readOrWriteAction.Equals("XPath")) { return(Initialize(typeof(XpathEditor), value.ToString())); } else if (readOrWriteAction.Equals("MessageContext") || readOrWriteAction.Equals("PromoteMessageContext")) { return(Initialize(typeof(MessageContextEditor), value.ToString())); } else if (readOrWriteAction.Equals("Constant")) { return(Initialize(typeof(ConstantEditor), value.ToString())); } else if (readOrWriteAction.Equals("BizTalkMacros")) { return(Initialize(typeof(BizTalkMacroEditor), value.ToString())); } else if (readOrWriteAction.Equals("XmlStructure")) { return(Initialize(typeof(XmlDocumentStructure), value.ToString())); } else { return(null); } }
protected override void FillListWithData(ITypeDescriptorContext context, ListView values) { ExtendedPropertyDescriptor propertyDescriptor = context.PropertyDescriptor as ExtendedPropertyDescriptor; if (propertyDescriptor.Name.Equals("ReadFrom", System.StringComparison.OrdinalIgnoreCase)) { values.Items.Add("Read from Http Header", 0); values.Items.Add("Read from XPath", 0); values.Items.Add("Read from Message Context", 0); values.Items.Add("Read Constant", 0); values.Items.Add("Read BizTalk Macros", 0); values.Items.Add("None", 0); } if (propertyDescriptor.Name.Equals("WriteTo", System.StringComparison.OrdinalIgnoreCase)) { values.Items.Add("Write to Http Header", 0); values.Items.Add("Write to XPath", 0); values.Items.Add("Write to Message Context", 0); values.Items.Add("Write to Message Context & Promote", 0); values.Items.Add("Alter Xml Structure", 0); } }
/// <summary> /// Initializes a new instance of the <see cref="ExtendedProperty"/> class. /// </summary> /// <param name="componentType">Type of the component to which the property will be added.</param> /// <param name="propertyName">Name of the property.</param> /// <param name="propertyType">Type of the property.</param> /// <param name="writable">if set to <c>true</c>, the property value can be set.</param> /// <param name="defaultValue">The default value of the property.</param> public ExtendedProperty(Type componentType, string propertyName, Type propertyType, bool writable, object defaultValue) { if (componentType == null) throw new ArgumentNullException("componentType"); if (propertyName == null) throw new ArgumentNullException("propertyName"); if (propertyName == "") throw new ArgumentException("propertyName"); if (propertyType == null) throw new ArgumentNullException("propertyType"); if (defaultValue != null && !propertyType.IsAssignableFrom(defaultValue.GetType())) throw new ArgumentException("defaultValue"); this.name = propertyName; this.type = propertyType; this.defaultValue = defaultValue; this.descriptor = new ExtendedPropertyDescriptor(componentType, propertyName, propertyType, writable, defaultValue); this.descriptor.ValueGet += new EventHandler<ExtendedPropertyEventArgs>(descriptor_ValueGet); this.descriptor.ValueSet += new EventHandler<ExtendedPropertyEventArgs>(descriptor_ValueSet); }