public void PASS_CreateFilter() { ExistsFilter filter = new ExistsFilter("field", "value"); Assert.IsNotNull(filter); Assert.AreEqual("field", filter.Field); Assert.AreEqual("value", filter.Value.ToString()); }
protected override void InternalValidate() { TaskLogger.LogEnter(); try { if (this.Identity == null) { ADObjectId orgContainerId = this.ConfigurationSession.GetOrgContainerId(); this.Identity = new ApprovalApplicationIdParameter(orgContainerId.GetDescendantId(new ADObjectId(string.Concat(new object[] { "CN=", base.ParameterSetName, ",", ApprovalApplication.ParentPathInternal }), Guid.Empty))); } else { base.WriteError(new ArgumentException(Strings.ErrorApprovalApplicationIdentityUnsupported), ErrorCategory.InvalidArgument, this.Identity); } base.InternalValidate(); ExistsFilter filter = new ExistsFilter(ApprovalApplicationSchema.ArbitrationMailboxesBacklink); ApprovalApplication[] array = this.ConfigurationSession.Find <ApprovalApplication>((ADObjectId)base.DataObject.Identity, QueryScope.Base, filter, null, 0); if (array.Length > 0) { base.WriteError(new CannotRemoveApprovalApplicationWithMailboxes(), ErrorCategory.PermissionDenied, this.Identity); } } finally { TaskLogger.LogExit(); } }
// Token: 0x06000DD9 RID: 3545 RVA: 0x00040694 File Offset: 0x0003E894 private void ConvertExistsFilter(ExistsFilter existsFilter) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)existsFilter.Property; if (adpropertyDefinition.IsSoftLinkAttribute) { switch (this.softLinkMode) { case SoftLinkMode.Enabled: this.ConvertExistsFilterInternal(existsFilter, true); return; case SoftLinkMode.Disabled: this.ConvertExistsFilterInternal(existsFilter, false); return; } this.IncrementFilterSize(); this.ldapFilter.Append("(|"); this.ConvertExistsFilterInternal(existsFilter, false); this.ConvertExistsFilterInternal(existsFilter, true); this.ldapFilter.Append(")"); return; } this.ConvertExistsFilterInternal(existsFilter, false); }
private IEnumerable <ExchangeVirtualDirectory> GetVirtualDirectories(ADObjectId serverId) { base.TraceInfo("GetVirtualDirectories: server = {0}", new object[] { serverId }); QueryFilter queryFilter = new ExistsFilter(ExchangeVirtualDirectorySchema.MetabasePath); if (this.VirtualDirectoryName != null) { queryFilter = new AndFilter(new QueryFilter[] { queryFilter, new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, this.VirtualDirectoryName) }); } ExchangeVirtualDirectory[] array = this.GetVirtualDirectories(serverId, queryFilter).ToArray <ExchangeVirtualDirectory>(); if (array.Length == 0) { if (this.VirtualDirectoryName != null) { base.WriteErrorAndMonitoringEvent(new ApplicationException(Strings.CasHealthWebAppVdirNotFoundError(this.ApplicationShortName, this.VirtualDirectoryName)), ErrorCategory.ObjectNotFound, null, 1010, this.MonitoringEventSource, true); } else { this.WriteWarning(Strings.CasHealthWebAppNoVirtualDirectories(this.ApplicationShortName, serverId.Name)); } } return(array); }
private static bool EvaluateExistsFilter(ExistsFilter existsFilter, IReadOnlyPropertyBag propertyBag) { object obj = propertyBag[existsFilter.Property]; PropertyError propertyError = obj as PropertyError; if (propertyError != null && propertyError.PropertyErrorCode == PropertyErrorCode.NotFound) { return(false); } if (propertyBag is ADPropertyBag || propertyBag is ADRawEntry) { if (obj == null) { return(false); } if (obj is string && string.IsNullOrEmpty((string)obj)) { return(false); } if (obj is SmtpAddress && !((SmtpAddress)obj).IsValidAddress) { return(false); } } return(true); }
public void SerializerExistsFilter() { JsonSerializer jsonSerializer = new JsonSerializer(); ExistsFilter existsFilter = new ExistsFilter("field"); string jsonString = jsonSerializer.Serialize(existsFilter); Console.WriteLine(jsonString); }
public void PASS_Serialize() { ExistsFilter filter = new ExistsFilter("field", "value"); string json = JsonConvert.SerializeObject(filter); Assert.IsNotNull(json); string expectedJson = "{\"exists\":{\"field\":\"value\"}}"; Assert.AreEqual(expectedJson, json); }
/// <summary> /// Generates the text for an ExistsFilter builder. /// </summary> /// <param name="item">The ExistsFilter builder to generate the text for.</param> protected internal override void VisitExistsFilter(ExistsFilter item) { Action visitor = () => { writer.Write("EXISTS"); item.Select.Accept(forSubCommand()); }; visitFilter(item, visitor); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { Dictionary<string, object> fieldDict = serializer.Deserialize<Dictionary<string, object>>(reader); if (fieldDict.ContainsKey(FilterTypeEnum.Exists.ToString())) fieldDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(fieldDict.First().Value.ToString()); ExistsFilter filter = new ExistsFilter(fieldDict.First().Key, fieldDict.First().Value.ToString()); filter.FilterName = fieldDict.GetStringOrDefault(FilterSerializer._FILTER_NAME); return filter; }
private static QueryFilter CreateMailEnabledFilter(bool exists) { QueryFilter queryFilter = new ExistsFilter(ADRecipientSchema.Alias); if (!exists) { return(new NotFilter(queryFilter)); } return(queryFilter); }
private static QueryFilter CreateMailboxEnabledFilter(bool exists) { QueryFilter queryFilter = new ExistsFilter(IADMailStorageSchema.ServerLegacyDN); if (!exists) { return(new NotFilter(queryFilter)); } return(queryFilter); }
// Token: 0x06000DD6 RID: 3542 RVA: 0x0003FD34 File Offset: 0x0003DF34 private void ConvertSinglePropertyFilter(SinglePropertyFilter queryFilter, QueryFilter parentFilter) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)queryFilter.Property; if (adpropertyDefinition.LdapDisplayName == null) { if (adpropertyDefinition.CustomFilterBuilderDelegate == null) { throw new ADFilterException(DirectoryStrings.ExceptionPropertyCannotBeSearchedOn(adpropertyDefinition.Name)); } ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter; if (comparisonFilter != null && comparisonFilter.ComparisonOperator == ComparisonOperator.NotEqual) { QueryFilter filter = adpropertyDefinition.CustomFilterBuilderDelegate(new ComparisonFilter(ComparisonOperator.Equal, comparisonFilter.Property, comparisonFilter.PropertyValue)); this.BuildLdapFilter(QueryFilter.NotFilter(filter), parentFilter); return; } QueryFilter queryFilter2 = adpropertyDefinition.CustomFilterBuilderDelegate(queryFilter); this.BuildLdapFilter(queryFilter2, parentFilter); return; } else { ComparisonFilter comparisonFilter2 = queryFilter as ComparisonFilter; if (comparisonFilter2 != null) { this.ConvertComparisonFilter(comparisonFilter2, parentFilter); return; } ExistsFilter existsFilter = queryFilter as ExistsFilter; if (existsFilter != null) { this.ConvertExistsFilter(existsFilter); return; } TextFilter textFilter = queryFilter as TextFilter; if (textFilter != null) { this.ConvertTextFilter(textFilter); return; } GenericBitMaskFilter genericBitMaskFilter = queryFilter as GenericBitMaskFilter; if (genericBitMaskFilter != null) { this.ConvertBitMaskFilter(genericBitMaskFilter); return; } InChainFilter inChainFilter = queryFilter as InChainFilter; if (inChainFilter != null) { this.ConvertInChainFilter(inChainFilter); } return; } }
public void FAIL_CreateFilter_Value() { try { ExistsFilter filter = new ExistsFilter("field", ""); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("value", ex.ParamName); } }
internal static QueryFilter ToNullComparisonFilter(this ExpressionType expressionType, PropertyDefinition propertyDefinition) { ExistsFilter existsFilter = new ExistsFilter(propertyDefinition); if (expressionType == ExpressionType.Equal) { return(new NotFilter(existsFilter)); } if (expressionType == ExpressionType.NotEqual) { return(existsFilter); } throw new UnsupportedExpressionException(Strings.UnsupportedOperatorWithNull(expressionType)); }
// Token: 0x06000DDA RID: 3546 RVA: 0x00040724 File Offset: 0x0003E924 private void ConvertExistsFilterInternal(ExistsFilter existsFilter, bool isSoftLink) { ADPropertyDefinition adpropertyDefinition = (ADPropertyDefinition)existsFilter.Property; string ldapDisplayName = adpropertyDefinition.LdapDisplayName; if (isSoftLink && adpropertyDefinition.IsSoftLinkAttribute) { ldapDisplayName = adpropertyDefinition.SoftLinkShadowProperty.LdapDisplayName; } this.IncrementFilterSize(); this.ldapFilter.Append("("); this.ldapFilter.Append(ldapDisplayName); this.ldapFilter.Append("=*)"); }
private static void GetNodesFromExpressionTree(QueryFilter queryFilter, Hashtable allowedProperties, List <FilterNode> filterNodes) { if (queryFilter != null) { CompositeFilter compositeFilter = queryFilter as CompositeFilter; TextFilter textFilter = queryFilter as TextFilter; ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter; ExistsFilter existsFilter = queryFilter as ExistsFilter; NotFilter notFilter = queryFilter as NotFilter; if (compositeFilter != null) { using (ReadOnlyCollection <QueryFilter> .Enumerator enumerator = compositeFilter.Filters.GetEnumerator()) { while (enumerator.MoveNext()) { QueryFilter queryFilter2 = enumerator.Current; FilterNode.GetNodesFromExpressionTree(queryFilter2, allowedProperties, filterNodes); } return; } } if (notFilter != null) { textFilter = (notFilter.Filter as TextFilter); existsFilter = (notFilter.Filter as ExistsFilter); comparisonFilter = (notFilter.Filter as ComparisonFilter); if ((textFilter == null && existsFilter == null && comparisonFilter == null) || (comparisonFilter != null && !typeof(bool).IsAssignableFrom(comparisonFilter.Property.Type))) { throw new InvalidOperationException(Strings.InvalidNotFilter.ToString()); } } if (textFilter != null) { FilterNode.GetNodeFromTextFilter(textFilter, allowedProperties, filterNodes, notFilter != null); return; } if (comparisonFilter != null) { FilterNode.GetNodeFromComparisonFilter(comparisonFilter, allowedProperties, filterNodes, notFilter != null); return; } if (existsFilter != null) { FilterNode.GetNodeFromExistsFilter(existsFilter, allowedProperties, filterNodes, null != notFilter); return; } throw new InvalidOperationException(Strings.UnsuportedFilterType(queryFilter.GetType()).ToString()); } }
private QueryFilter CreateAutoTaggedSearchFolderQuery() { QueryFilter queryFilter = new ExistsFilter(StoreObjectSchema.PolicyTag); QueryFilter queryFilter2 = new AndFilter(new QueryFilter[] { new ExistsFilter(StoreObjectSchema.RetentionFlags), new BitMaskFilter(StoreObjectSchema.RetentionFlags, 4UL, true) }); return(new AndFilter(new QueryFilter[] { queryFilter, queryFilter2 })); }
internal override QueryFilter SmartFilterToNativeFilter(SinglePropertyFilter filter) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, this.backingPropertyDefinition, ((StoreObjectId)comparisonFilter.PropertyValue).GetBytes())); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(this.backingPropertyDefinition)); } throw base.CreateInvalidFilterConversionException(filter); }
// Token: 0x060019C6 RID: 6598 RVA: 0x0006CC9C File Offset: 0x0006AE9C internal static QueryFilter RoleGroupTypeFilterBuilder(SinglePropertyFilter filter) { RoleGroupType roleGroupType = (RoleGroupType)ADObject.PropertyValueFromEqualityFilter(filter); QueryFilter queryFilter = new ExistsFilter(ADGroupSchema.ForeignGroupSid); QueryFilter result = new ExistsFilter(ADGroupSchema.LinkedPartnerGroupAndOrganizationId); if (roleGroupType == RoleGroupType.Linked) { return(queryFilter); } if (roleGroupType == RoleGroupType.PartnerLinked) { return(result); } return(new NotFilter(queryFilter)); }
internal static QueryFilter ConversationIdBasedSmartFilterToNativeFilter(this SmartPropertyDefinition conversationIdSmartPropertyDefinition, SinglePropertyFilter filter, PropertyDefinition conversationIdNativePropertyDefinition) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { ConversationId conversationId = (ConversationId)comparisonFilter.PropertyValue; return(new ComparisonFilter(comparisonFilter.ComparisonOperator, conversationIdNativePropertyDefinition, conversationId.GetBytes())); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(conversationIdNativePropertyDefinition)); } throw conversationIdSmartPropertyDefinition.CreateInvalidFilterConversionException(filter); }
protected QueryFilter SinglePropertySmartFilterToNativeFilter(QueryFilter filter, PropertyDefinition nativeProperty) { MultivaluedInstanceComparisonFilter multivaluedInstanceComparisonFilter = filter as MultivaluedInstanceComparisonFilter; if (multivaluedInstanceComparisonFilter != null) { return(new MultivaluedInstanceComparisonFilter(multivaluedInstanceComparisonFilter.ComparisonOperator, nativeProperty, multivaluedInstanceComparisonFilter.PropertyValue)); } ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, nativeProperty, comparisonFilter.PropertyValue)); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(nativeProperty)); } TextFilter textFilter = filter as TextFilter; if (textFilter != null) { return(new TextFilter(nativeProperty, textFilter.Text, textFilter.MatchOptions, textFilter.MatchFlags)); } BitMaskFilter bitMaskFilter = filter as BitMaskFilter; if (bitMaskFilter != null) { return(new BitMaskFilter(nativeProperty, bitMaskFilter.Mask, bitMaskFilter.IsNonZero)); } BitMaskAndFilter bitMaskAndFilter = filter as BitMaskAndFilter; if (bitMaskAndFilter != null) { return(new BitMaskAndFilter(nativeProperty, bitMaskAndFilter.Mask)); } BitMaskOrFilter bitMaskOrFilter = filter as BitMaskOrFilter; if (bitMaskOrFilter != null) { return(new BitMaskOrFilter(nativeProperty, bitMaskOrFilter.Mask)); } throw this.CreateInvalidFilterConversionException(filter); }
private QueryFilter BuildExistsFilter(PropertyDefinition[] properties) { if (properties.Length == 1) { return(new ExistsFilter(properties[0])); } if (properties.Length > 1) { QueryFilter[] array = new QueryFilter[properties.Length]; for (int i = 0; i < properties.Length; i++) { array[i] = new ExistsFilter(properties[i]); } return(new OrFilter(array)); } return(null); }
internal ADVirtualListView(IDirectorySession session, ADObjectId rootId, ADObjectId[] addressListIds, SortBy sortBy, int rowsToPrefetch, IEnumerable <PropertyDefinition> properties) : base(session, rootId, QueryScope.SubTree, sortBy) { if (properties == null) { throw new ArgumentNullException("properties"); } if (sortBy == null) { throw new ArgumentNullException("sortBy"); } if (rowsToPrefetch < 1) { throw new ArgumentOutOfRangeException("rowsToPrefetch"); } this.rowsToPrefetch = rowsToPrefetch; QueryFilter[] array; if (addressListIds == null) { array = new QueryFilter[2]; array[0] = new ExistsFilter(ADRecipientSchema.AddressListMembership); } else { array = new QueryFilter[addressListIds.Length + 1]; for (int i = 0; i < addressListIds.Length; i++) { array[i] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, addressListIds[i]); } } array[array.Length - 1] = new ExistsFilter(ADRecipientSchema.DisplayName); QueryFilter queryFilter = new AndFilter(array); QueryFilter queryFilter2 = (addressListIds == null) ? queryFilter : new ExistsFilter(ADObjectSchema.ObjectClass); this.requestedProperties = properties; ADScope readScope = session.GetReadScope(rootId, ADVirtualListView.dummyADRawEntry); ADObject adobject; string[] ldapAttributes; session.GetSchemaAndApplyFilter(ADVirtualListView.dummyADRawEntry, readScope, out adobject, out ldapAttributes, ref queryFilter2, ref properties); base.LdapAttributes = ldapAttributes; this.properties = properties; base.LdapFilter = LdapFilterBuilder.LdapFilterFromQueryFilter((addressListIds == null) ? queryFilter2 : queryFilter, false, base.Session.SessionSettings.PartitionSoftLinkMode, base.Session.SessionSettings.IsTenantScoped); this.vlvRequestControl = new VlvRequestControl(); this.vlvRequestControl.AfterCount = this.rowsToPrefetch; base.DirectoryControls.Add(this.vlvRequestControl); }
protected QueryFilter SinglePropertyNativeFilterToSmartFilter(QueryFilter filter, PropertyDefinition nativeProperty) { SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter; if (singlePropertyFilter != null && singlePropertyFilter.Property.Equals(nativeProperty)) { MultivaluedInstanceComparisonFilter multivaluedInstanceComparisonFilter = filter as MultivaluedInstanceComparisonFilter; if (multivaluedInstanceComparisonFilter != null) { return(new MultivaluedInstanceComparisonFilter(multivaluedInstanceComparisonFilter.ComparisonOperator, this, multivaluedInstanceComparisonFilter.PropertyValue)); } ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, this, comparisonFilter.PropertyValue)); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(this)); } TextFilter textFilter = filter as TextFilter; if (textFilter != null) { return(new TextFilter(this, textFilter.Text, textFilter.MatchOptions, textFilter.MatchFlags)); } BitMaskFilter bitMaskFilter = filter as BitMaskFilter; if (bitMaskFilter != null) { return(new BitMaskFilter(this, bitMaskFilter.Mask, bitMaskFilter.IsNonZero)); } BitMaskAndFilter bitMaskAndFilter = filter as BitMaskAndFilter; if (bitMaskAndFilter != null) { return(new BitMaskAndFilter(this, bitMaskAndFilter.Mask)); } BitMaskOrFilter bitMaskOrFilter = filter as BitMaskOrFilter; if (bitMaskOrFilter != null) { return(new BitMaskOrFilter(this, bitMaskOrFilter.Mask)); } } return(null); }
internal override QueryFilter NativeFilterToSmartFilter(QueryFilter filter) { SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter; if (singlePropertyFilter != null && singlePropertyFilter.Property.Equals(this.backingPropertyDefinition)) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, this, StoreObjectId.Parse((byte[])comparisonFilter.PropertyValue, 0))); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(this)); } } return(null); }
// Token: 0x060019C3 RID: 6595 RVA: 0x0006CA10 File Offset: 0x0006AC10 internal static QueryFilter ManagedByFilterBuilder(SinglePropertyFilter filter) { QueryFilter result; if (filter is ComparisonFilter) { ComparisonFilter comparisonFilter = (ComparisonFilter)filter; if (comparisonFilter.ComparisonOperator == ComparisonOperator.Equal) { result = new OrFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.RawManagedBy, comparisonFilter.PropertyValue), new ComparisonFilter(ComparisonOperator.Equal, ADGroupSchema.CoManagedBy, comparisonFilter.PropertyValue) }); } else { if (comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedOperatorForProperty(comparisonFilter.Property.Name, comparisonFilter.ComparisonOperator.ToString())); } result = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.NotEqual, ADGroupSchema.RawManagedBy, comparisonFilter.PropertyValue), new ComparisonFilter(ComparisonOperator.NotEqual, ADGroupSchema.CoManagedBy, comparisonFilter.PropertyValue) }); } } else { if (!(filter is ExistsFilter)) { throw new ADFilterException(DirectoryStrings.ExceptionUnsupportedFilterForPropertyMultiple(filter.Property.Name, filter.GetType(), typeof(ComparisonFilter), typeof(ExistsFilter))); } ExistsFilter existsFilter = (ExistsFilter)filter; result = new OrFilter(new QueryFilter[] { new ExistsFilter(ADGroupSchema.RawManagedBy), new ExistsFilter(ADGroupSchema.CoManagedBy) }); } return(result); }
private static void GetNodeFromExistsFilter(ExistsFilter existsFilter, Hashtable allowedProperties, List <FilterNode> filterNodes, bool isNotFilter) { if (allowedProperties.ContainsKey(existsFilter.Property.Name)) { FilterNode filterNode = new FilterNode(); filterNode.FilterablePropertyDescription = (FilterablePropertyDescription)allowedProperties[existsFilter.Property.Name]; if (isNotFilter) { filterNode.Operator = PropertyFilterOperator.NotPresent; } else { filterNode.Operator = PropertyFilterOperator.Present; } filterNodes.Add(filterNode); return; } throw new InvalidOperationException(Strings.UnknownFilterableProperty(existsFilter.Property.Name).ToString()); }
internal static QueryFilter NativeFilterToConversationIdBasedSmartFilter(this SmartPropertyDefinition conversationIdSmartPropertyDefinition, QueryFilter filter, PropertyDefinition conversationIdNativePropertyDefinition) { SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter; if (singlePropertyFilter != null && singlePropertyFilter.Property.Equals(conversationIdNativePropertyDefinition)) { ComparisonFilter comparisonFilter = filter as ComparisonFilter; if (comparisonFilter != null) { return(new ComparisonFilter(comparisonFilter.ComparisonOperator, conversationIdSmartPropertyDefinition, ConversationId.Create((byte[])comparisonFilter.PropertyValue))); } ExistsFilter existsFilter = filter as ExistsFilter; if (existsFilter != null) { return(new ExistsFilter(conversationIdSmartPropertyDefinition)); } } return(null); }
public override void BuildFilter <T>(object query, object options, ref FilterContainer container) { var fieldValuesQuery = query as IFieldConditionsQuery; if (fieldValuesQuery?.FieldConditions == null || fieldValuesQuery.FieldConditions.Count <= 0) { return; } foreach (var fieldValue in fieldValuesQuery.FieldConditions) { switch (fieldValue.Operator) { case ComparisonOperator.Equals: container &= new TermFilter { Field = fieldValue.Field, Value = fieldValue.Value }; break; case ComparisonOperator.NotEquals: container &= new NotFilter { Filter = FilterContainer.From(new TermFilter { Field = fieldValue.Field, Value = fieldValue.Value }) }; break; case ComparisonOperator.IsEmpty: container &= new MissingFilter { Field = fieldValue.Field }; break; case ComparisonOperator.HasValue: container &= new ExistsFilter { Field = fieldValue.Field }; break; } } }
private static Query BuildSinglePropertyQuery(SinglePropertyFilter singlePropertyFilter, Dictionary <PropertyDefinition, int> propertyDefinitionToColumnMap) { int index; if (!propertyDefinitionToColumnMap.TryGetValue(singlePropertyFilter.Property, out index)) { throw new ArgumentException(string.Format("{0} specified in filter is not present in propertyDefinition columns", singlePropertyFilter.Property)); } ComparisonFilter comparisonFilter = singlePropertyFilter as ComparisonFilter; if (comparisonFilter != null) { return(Query.BuildComparisionQuery(comparisonFilter, index)); } ExistsFilter existsFilter = singlePropertyFilter as ExistsFilter; if (existsFilter != null) { return(new ExistsQuery(index)); } throw new NotSupportedException(string.Format("Filter:({0}) not supported", singlePropertyFilter)); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { ExistsFilter existsFilter = (ExistsFilter)value; if (existsFilter == null) { return; } /* * { * "exists" : { "field" : "user" } * } */ writer.WriteStartObject(); writer.WritePropertyName("exists"); writer.WriteStartObject(); writer.WritePropertyName("field"); writer.WriteValue(existsFilter.Filed); writer.WriteEndObject(); writer.WriteEndObject(); }
internal ExistRestrictionData(StoreSession storeSession, ExistsFilter filter) { this.PropTag = base.GetPropTagFromDefinition(storeSession, filter.Property); }
protected override Expression VisitBinary(BinaryExpression node) { if (node.NodeType == ExpressionType.AndAlso || node.NodeType == ExpressionType.And) { if (node.Left is BinaryExpression && node.Right is BinaryExpression) { var leftBinary = (BinaryExpression)node.Left; var rightBinary = (BinaryExpression)node.Right; if (leftBinary.NodeType == ExpressionType.LessThan && rightBinary.NodeType == ExpressionType.GreaterThan) { } } var andFilter = new AndFilter(); AddFilter(andFilter); return(VisitWithFilterInScope(() => base.VisitBinary(node), filter => andFilter.Filters.Add(filter))); } if (node.NodeType == ExpressionType.OrElse || node.NodeType == ExpressionType.Or) { var orFilter = new OrFilter(); AddFilter(orFilter); return(VisitWithFilterInScope(() => base.VisitBinary(node), filter => orFilter.Filters.Add(filter))); } if (node.NodeType == ExpressionType.Equal || node.NodeType == ExpressionType.NotEqual || NodeTypeIsSizeComparison(node.NodeType)) { Expression valueExpression = null; var fieldName = GetFilterableFieldName(node.Left); if (fieldName != null) { valueExpression = node.Right; } else { fieldName = GetFilterableFieldName(node.Right); valueExpression = node.Left; } if (fieldName != null) { Filter filterToAdd = null; if (node.NodeType == ExpressionType.Equal) { var value = EvaluateExpression(valueExpression); if (value != null) { filterToAdd = CreateTermFilter(fieldName, value); } else { filterToAdd = new NotFilter(new ExistsFilter(fieldName)); } } else if (node.NodeType == ExpressionType.NotEqual) { var value = EvaluateExpression(valueExpression); if (value != null) { var termFilter = CreateTermFilter(fieldName, valueExpression); filterToAdd = new NotFilter(termFilter); } else { filterToAdd = new ExistsFilter(fieldName); } } else if (node.NodeType == ExpressionType.GreaterThan) { filterToAdd = CreateGreaterThanFilter(fieldName, valueExpression, false); } else if (node.NodeType == ExpressionType.GreaterThanOrEqual) { filterToAdd = CreateGreaterThanFilter(fieldName, valueExpression, true); } else if (node.NodeType == ExpressionType.LessThan) { filterToAdd = CreateLessThanFilter(fieldName, valueExpression, false); } else if (node.NodeType == ExpressionType.LessThanOrEqual) { filterToAdd = CreateLessThanFilter(fieldName, valueExpression, true); } AddFilter(filterToAdd); return(node); } } return(base.VisitBinary(node)); }
// Token: 0x06000DE3 RID: 3555 RVA: 0x00040D24 File Offset: 0x0003EF24 private void CheckVirtualIndexOnIdOrAbMembership(CompositeFilter filter) { if (this.skipCheckVirtualIndex) { return; } bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; Guid a = Guid.Empty; string text = string.Empty; foreach (QueryFilter queryFilter in filter.Filters) { if (queryFilter is OrFilter) { flag = true; } else { ComparisonFilter comparisonFilter = queryFilter as ComparisonFilter; if (comparisonFilter != null) { if (comparisonFilter.ComparisonOperator == ComparisonOperator.Equal) { if (comparisonFilter.Property == ADObjectSchema.Id) { ADObjectId adobjectId = (ADObjectId)comparisonFilter.PropertyValue; a = adobjectId.ObjectGuid; text = adobjectId.ToDNString(); } else if (comparisonFilter.Property == ADObjectSchema.Guid) { a = (Guid)comparisonFilter.PropertyValue; } else if (comparisonFilter.Property == ADObjectSchema.DistinguishedName) { text = (string)comparisonFilter.PropertyValue; } else if (comparisonFilter.Property == ADRecipientSchema.AddressListMembership) { flag2 = true; } else if (comparisonFilter.Property == ADRecipientSchema.DisplayName) { flag3 = true; } } } else { ExistsFilter existsFilter = queryFilter as ExistsFilter; if (existsFilter != null) { if (existsFilter.Property == ADRecipientSchema.DisplayName) { flag3 = true; } } else if (queryFilter is AmbiguousNameResolutionFilter) { flag4 = true; } } } } if (flag2 && !flag3 && !flag4 && (text != string.Empty || a != Guid.Empty || flag)) { this.ldapFilter.Append("(displayName=*)"); } if (flag) { if (text != string.Empty && !text.Contains(",CN=DeletedObjects,")) { this.ldapFilter.Append("(objectCategory=*)"); return; } if (a != Guid.Empty) { this.ldapFilter.Append("(objectCategory=*)"); } } }