public static int[] BuildColumnMap(ResultSet resultSet) { if (resultSet == null) { throw new ArgumentNullException(nameof(resultSet)); } var columns = new List <Tuple <string, int> >(); for (int i = 0; i < resultSet.FieldCount; i++) { columns.Add(Tuple.Create(resultSet.GetFieldName(i), i)); } columns.Sort((a, b) => String.Compare(HumanText.ToHuman(a.Item1), HumanText.ToHuman(b.Item1), StringComparison.CurrentCultureIgnoreCase)); var columnMap = new int[columns.Count]; for (int i = 0; i < columns.Count; i++) { columnMap[columns[i].Item2] = i; } return(columnMap); }
private void Reload() { var entities = new List <EntitySchema>(); string filter = _filter.Text.ToLower(); foreach (var item in _api.GetSchema().Entities) { var entity = _api.GetEntitySchema(item); bool include = true; if (filter.Length > 0) { include = entity.Name.ToLower().Contains(filter) || (entity.Comments != null && entity.Comments.ToLower().Contains(filter)); } if (include) { entities.Add(entity); } } entities.Sort(EntitySchemaComparer.Instance); _entities.BeginUpdate(); _entities.Items.Clear(); string header = null; bool hadSelected = false; foreach (var entity in entities) { var name = new EntityName(entity.Name); if (header != name.Header) { _entities.Items.Add(new HeaderDrawer(HumanText.ToHuman(name.Header))); header = name.Header; } _entities.Items.Add(new EntityDrawer(entity)); if (!hadSelected) { hadSelected = true; _entities.SelectedIndex = _entities.Items.Count - 1; } } _entities.EndUpdate(); }