private void FillList(ServiceContractConfiguration contract, MessageTypeMapControl editor) { // Add data to the ListView. ListViewItem listviewitem; string messageSource; string baseUrn = contract.ServiceBroker.Parent.ExtendedProperties["BaseUrn"].Value.ToString(); foreach (MessageType item in contract.ServiceBroker.MessageTypes) { if (item.Name.StartsWith(baseUrn + "messagetype", StringComparison.OrdinalIgnoreCase)) { //Default message source name messageSource = "Initiator"; // Create ListView data. listviewitem = new ListViewItem(item.Name); if (contract.MessageTypeMappings.Contains(item.Name)) { listviewitem.Checked = true; messageSource = contract.MessageTypeMappings[item.Name].ToString(); } listviewitem.SubItems.Add(messageSource); editor.MessageMapListView.Items.Add(listviewitem); } } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { object retvalue = value; //Get the editor service from the provider, to perform the dropdown. if (provider != null) { m_FormEditorService = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService)); } if (m_FormEditorService != null) { ServiceContractConfiguration contract = (ServiceContractConfiguration)context.Instance; MessageTypeMapControl editor = new MessageTypeMapControl(); FillList(contract, editor); m_FormEditorService.DropDownControl(editor); //File ListView with MessageTypeMappings contract.MessageTypeMappings.Clear(); for (int i = 0; i < editor.MessageMapListView.Items.Count; i++) { ListViewItem lvItem = editor.MessageMapListView.Items[i]; if (lvItem.Checked) { contract.MessageTypeMappings.Add(lvItem.SubItems[0].Text, MessageSourceFromString(lvItem.SubItems[1].Text)); } } //Done with editor so dispose editor.Dispose(); return(contract.MessageTypeMappings); } return(retvalue); }