private void LoadEntity() { if (entityListView.SelectedItems.Count == 0) return; var emd = new EntityMetadataInfo((EntityMetadata)entityListView.SelectedItems[0].Tag); WorkAsync("Loading Entity...", dwe => { var request = new RetrieveEntityRequest { EntityFilters = EntityFilters.All, LogicalName = ((EntityMetadataInfo)dwe.Argument).LogicalName }; var response = (RetrieveEntityResponse)Service.Execute(request); dwe.Result = response.EntityMetadata; }, wce => { var emdFull = (EntityMetadata)wce.Result; TabPage tab; if (mainTabControl.TabPages.ContainsKey(emd.SchemaName)) { tab = mainTabControl.TabPages[emd.SchemaName]; ((EntityPropertiesControl)tab.Controls[0]).RefreshContent(emdFull); } else { mainTabControl.TabPages.Add(emd.SchemaName, emd.SchemaName); tab = mainTabControl.TabPages[emd.SchemaName]; var epc = new EntityPropertiesControl(emdFull, lvcSettings) { Dock = DockStyle.Fill, Name = emdFull.SchemaName }; epc.OnColumnSettingsUpdated += epc_OnColumnSettingsUpdated; tab.Controls.Add(epc); mainTabControl.SelectTab(tab); } }, emd); }
private List<ListViewItem> BuildEntityItems(IEnumerable<EntityMetadata> emds) { if (emds == null) return new List<ListViewItem>(); var items = new List<ListViewItem>(); // Stores each property in a listviewitem foreach (var metadata in emds.OrderBy(m => m.LogicalName)) { var emd = new EntityMetadataInfo(metadata); var item = new ListViewItem(emd.LogicalName) { Tag = metadata }; item.SubItems.Add(emd.SchemaName); item.SubItems.Add(emd.ObjectTypeCode.ToString(CultureInfo.InvariantCulture)); AddSecondarySubItems(typeof(EntityMetadataInfo), ListViewColumnsSettings.EntityFirstColumns, lvcSettings.EntitySelectedAttributes, emd, item); items.Add(item); } return items; }