private void AssignProperties() { this.propertyColumn.Items.Clear(); GraphApiEntityType entity = GetEntityType(this.resourceComboBox.Text); if (entity == null) { return; } this.propertyColumn.Items.AddRange(entity.Properties.Where(p => p.Filterable).Select(p => p.Name).ToArray()); }
private void UpdateUrlBuilder() { this.UrlBuilder.ResourceFirst = this.resourceComboBox.Text; this.UrlBuilder.ResourceSecond = null; this.UrlBuilder.ResourceId = null; this.UrlBuilder.FilterComponents.Clear(); for (int index = 0; index < this.queryGridView.Rows.Count; index++) { DataGridViewRow row = this.queryGridView.Rows[index]; if (row.IsNewRow) { continue; } string logicalOperator = row.Cells[LogicalOperatorColumnName].Value as string; string comparisonOperator = row.Cells[ComparisonOperatorColumnName].Value as string; string propertyName = row.Cells[PropertyColumnName].Value as string; string value = row.Cells[ValueColumnName].Value as string; if ((index != 0 && String.IsNullOrWhiteSpace(logicalOperator) || String.IsNullOrWhiteSpace(comparisonOperator) || String.IsNullOrWhiteSpace(propertyName) || String.IsNullOrWhiteSpace(value))) { return; } GraphApiEntityType entity = GetEntityType(this.resourceComboBox.Text); if (entity == null) { return; } GraphApiProperty property = entity.Properties.SingleOrDefault(p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase)); if (property == null) { return; } GraphApiUrlFilterComponent filterComponent = new GraphApiUrlFilterComponent { LogicalOperator = index > 0 ? logicalOperator : null, Property = property, ComparisonOperator = comparisonOperator, Value = value }; this.UrlBuilder.FilterComponents.Add(filterComponent); } }
private void SetComparisonOperators(DataGridViewRow row) { string propertyName = (string)row.Cells[PropertyColumnName].Value; GraphApiEntityType entity = GetEntityType(this.resourceComboBox.Text); GraphApiProperty property = entity.Properties.Single(p => p.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase)); DataGridViewComboBoxCell operatorCell = (DataGridViewComboBoxCell)row.Cells[ComparisonOperatorColumnName]; string operatorValue = operatorCell.Value as string; operatorCell.Items.Clear(); string[] operators = property.GetAllowedComparisonOperators(); operatorCell.Items.AddRange(operators); if (!operators.Contains(operatorValue)) { operatorCell.Value = null; } }