public static string GenerateSqlFor(IFilterCondition condition) { if (condition is TrueCondition) { return("1=1"); } if (condition is IsNullCondition) { return(IsNullConditionGenerator.GenerateSqlFor((IsNullCondition)condition)); } if (condition is MatchCondition) { return(MatchConditionSqlGenerator.GenerateSqlFor((MatchCondition)condition)); } if (condition is AndCondition) { return(AndConditionSqlGenerator.GenerateSqlFor((AndCondition)condition)); } if (condition is OrCondition) { return(OrConditionSqlGenerator.GenerateSqlFor((OrCondition)condition)); } if (condition is NotCondition) { return(NotConditionSqlGenerator.GenerateSqlFor((NotCondition)condition)); } throw new NotSupportedException(); }
public static QueriableItem Create(IValueProvider valueProvider, IFilterCondition[] conditions) { return new QueriableItem { Conditions = conditions, ValueProvider = valueProvider }; }
public static string GenerateSqlFor(IFilterCondition condition) { if (condition is TrueCondition) return "1=1"; if (condition is IsNullCondition) return IsNullConditionGenerator.GenerateSqlFor((IsNullCondition) condition); if (condition is MatchCondition) return MatchConditionSqlGenerator.GenerateSqlFor((MatchCondition) condition); if (condition is AndCondition) return AndConditionSqlGenerator.GenerateSqlFor((AndCondition) condition); if (condition is OrCondition) return OrConditionSqlGenerator.GenerateSqlFor((OrCondition) condition); if (condition is NotCondition) return NotConditionSqlGenerator.GenerateSqlFor((NotCondition) condition); throw new NotSupportedException(); }
/// <summary> /// Filter using a single filtering condition /// </summary> public static IEnumerable <T> FilterValues(IEnumerable <T> values, IFilterCondition <T> filterCondition) { List <T> filteredValues = new List <T>(); foreach (var value in values) { if (filterCondition.Condition(value)) { filteredValues.Add(value); } } return(filteredValues); }
public static List <int> FilterValues(List <int> values, IFilterCondition filterCondition) { List <int> filteredValues = new List <int>(); foreach (var value in values) { if (filterCondition.Condition(value)) { filteredValues.Add(value); } } return(filteredValues); }
private RelationToContextEnum EvaluateCondition(ConditionEvaluationContext context, IFilterCondition condition) { if (condition.Subject == context.CurrentRuntimeContextItem.Key) { bool evaluationResult = condition.Evaluate(context); if (condition.Negate) { evaluationResult = !evaluationResult; } return evaluationResult ? RelationToContextEnum.True : RelationToContextEnum.False; } return RelationToContextEnum.Neutral; }
public static ObservableCollection <Customer> FilterValues(ObservableCollection <Customer> customers, IFilterCondition ifc) { ObservableCollection <Customer> fileredValues = new ObservableCollection <Customer>(); foreach (Customer costumer in customers) { if (ifc.Condition(costumer)) { fileredValues.Add(costumer); } } return(fileredValues); }
public static ObservableCollection <LicensSupplier> FilterValues1(ObservableCollection <LicensSupplier> licenses, IFilterCondition ifc) { ObservableCollection <LicensSupplier> fileredValues1 = new ObservableCollection <LicensSupplier>(); foreach (LicensSupplier licens in licenses) { if (ifc.Condition1(licens)) { fileredValues1.Add(licens); } } return(fileredValues1); }
public WindowsServiceBusSubscriptionMessageReceiver(IQueueManager queueManager, string topicPath, string subscriptionName, IFilterCondition filterCondition, ConcurrentHandlerLimitSetting concurrentHandlerLimit, IBrokeredMessageFactory brokeredMessageFactory, IGlobalHandlerThrottle globalHandlerThrottle, ILogger logger) : base(concurrentHandlerLimit, globalHandlerThrottle, logger) { _queueManager = queueManager; _topicPath = topicPath; _subscriptionName = subscriptionName; _filterCondition = filterCondition; _brokeredMessageFactory = brokeredMessageFactory; _logger = logger; }
public WindowsServiceBusSubscriptionMessageReceiver(IQueueManager queueManager, string topicPath, string subscriptionName, IFilterCondition filterCondition, ConcurrentHandlerLimitSetting concurrentHandlerLimit, IBrokeredMessageFactory brokeredMessageFactory, IGlobalHandlerThrottle globalHandlerThrottle, ILogger logger) : base(concurrentHandlerLimit, globalHandlerThrottle, logger) { _queueManager = queueManager; _topicPath = topicPath; _subscriptionName = subscriptionName; _filterCondition = filterCondition; _brokeredMessageFactory = brokeredMessageFactory; _logger = logger; }
private async Task <RawDataInformationDto[]> ListRawDataByUuidList(RawDataEntityDto entity, string[] uuids, IFilterCondition filter, CancellationToken cancellationToken = default) { StringUuidTools.CheckUuids(entity, uuids); var requestPath = $"rawData/{entity}"; var parameterDefinitions = new List <ParameterDefinition>(); if (filter != null) { var filterTree = ((FilterCondition)filter).BuildFilterTree(); var filterString = new FilterTreeFormatter().FormatString(filterTree); var filterParameter = ParameterDefinition.Create("filter", filterString); parameterDefinitions.Add(filterParameter); } //Split into multiple parameter sets to limit uuid parameter lenght var splitter = new ParameterSplitter(this, requestPath); var collectionParameter = CollectionParameterFactory.Create("uuids", uuids); var parameterSets = splitter.SplitAndMerge(collectionParameter, parameterDefinitions); //Execute requests in parallel var requests = parameterSets .Select(set => RequestBuilder.CreateGet(requestPath, set.ToArray())) .Select(request => _RestClient.Request <RawDataInformationDto[]>(request, cancellationToken)); var result = await Task.WhenAll(requests).ConfigureAwait(false); return(result.SelectMany(r => r).ToArray()); }
private Task <RawDataInformationDto[]> ListRawDataForAllEntities(RawDataEntityDto entity, [NotNull] IFilterCondition filter, CancellationToken cancellationToken = default) { if (filter == null) { throw new ArgumentNullException(nameof(filter)); } var requestPath = $"rawData/{entity}"; var parameterDefinitionList = new List <ParameterDefinition>(); var filterTree = ((FilterCondition)filter).BuildFilterTree(); var filterString = new FilterTreeFormatter().FormatString(filterTree); var filterParameter = ParameterDefinition.Create("filter", filterString); parameterDefinitionList.Add(filterParameter); return(_RestClient.Request <RawDataInformationDto[]>(RequestBuilder.CreateGet(requestPath, parameterDefinitionList.ToArray()), cancellationToken)); }
public NotCondition(IFilterCondition conditionToNegate) { ConditionToNegate = conditionToNegate; }
public TranslateFromStringValueProvider(IStringToValueTranslator translator, string value, IFilterCondition[] filterConditions) { this.Translator = translator; this.Value = value; this.FilterConditions = filterConditions; }
public string GenerateFor(IFilterCondition filterCondition) { return(ConditionSqlGenerator.GenerateSqlFor(filterCondition)); }
public Task <SubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition) { return(Task.Run(() => { EnsureSubscriptionExists(topicPath, subscriptionName); var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName), new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName)); var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition); var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition); return _retry.Do(() => { var subscriptionClient = _messagingFactory() .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete); subscriptionClient.ReplaceFilter("$Default", filterSql); return subscriptionClient; }, "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " + filterCondition); }).ConfigureAwaitFalse()); }
internal static bool MatchesFilter(this NimbusMessage nimbusMessage, IFilterCondition filterCondition) { var isMatch = filterCondition.IsMatch(nimbusMessage.Properties); return isMatch; }
public INimbusMessageReceiver GetTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filter) { var key = "{0}/{1}".FormatWith(topicPath, subscriptionName); return _topicMessageReceivers.GetOrAdd(key, k => CreateTopicReceiver(topicPath, subscriptionName, filter)); }
private INimbusMessageReceiver CreateTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition) { var receiver = new WindowsServiceBusSubscriptionMessageReceiver(_queueManager, topicPath, subscriptionName, filterCondition, _concurrentHandlerLimit, _brokeredMessageFactory, _globalHandlerThrottle, _logger); _garbageMan.Add(receiver); return receiver; }
public NotCondition(IFilterCondition conditionToNegate) { ConditionToNegate = conditionToNegate; }
public Task<SubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition) { return Task.Run(() => { EnsureSubscriptionExists(topicPath, subscriptionName); var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName), new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName)); var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition); var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition); return _retry.Do(() => { var subscriptionClient = _messagingFactory() .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete); subscriptionClient.ReplaceFilter("$Default", filterSql); return subscriptionClient; }, "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " + filterCondition); }).ConfigureAwaitFalse(); }
public string GenerateFor(IFilterCondition filterCondition) { return ConditionSqlGenerator.GenerateSqlFor(filterCondition); }
private INimbusMessageReceiver CreateTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition) { var receiver = new WindowsServiceBusSubscriptionMessageReceiver(_queueManager, topicPath, subscriptionName, filterCondition, _concurrentHandlerLimit, _brokeredMessageFactory, _globalHandlerThrottle, _logger); _garbageMan.Add(receiver); return(receiver); }
internal static bool MatchesFilter(this NimbusMessage nimbusMessage, IFilterCondition filterCondition) { var isMatch = filterCondition.IsMatch(nimbusMessage.Properties); return(isMatch); }
public INimbusMessageReceiver GetTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filter) { var subscription = new Subscription(topicPath, subscriptionName); return _container.ResolveWithOverrides<InProcessSubscriptionReceiver>(subscription); }
public Task <ISubscriptionClient> CreateSubscriptionReceiver(string topicPath, string subscriptionName, IFilterCondition filterCondition) { const string ruleName = "$Default"; return(Task.Run(() => { EnsureSubscriptionExists(topicPath, subscriptionName); var myOwnSubscriptionFilterCondition = new OrCondition(new MatchCondition(MessagePropertyKeys.RedeliveryToSubscriptionName, subscriptionName), new IsNullCondition(MessagePropertyKeys.RedeliveryToSubscriptionName)); var combinedCondition = new AndCondition(filterCondition, myOwnSubscriptionFilterCondition); var filterSql = _sqlFilterExpressionGenerator.GenerateFor(combinedCondition); return _retry.Do(async() => { var subscriptionClient = _connectionManager .CreateSubscriptionClient(topicPath, subscriptionName, ReceiveMode.ReceiveAndDelete); var rules = await subscriptionClient.GetRulesAsync(); if (rules.Any(r => r.Name == ruleName)) { await subscriptionClient.RemoveRuleAsync(ruleName); } await subscriptionClient.AddRuleAsync(ruleName, new SqlFilter(filterSql)); return subscriptionClient; }, "Creating subscription receiver for topic " + topicPath + " and subscription " + subscriptionName + " with filter expression " + filterCondition); }).ConfigureAwaitFalse()); }
public ConditionEvaluation(RelationToContextEnum relationToContext, ConditionEvaluationContext context, IFilterCondition condition) { RelationToContext = relationToContext; Context = context; Condition = condition; }
public INimbusMessageReceiver GetTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filter) { var key = "{0}/{1}".FormatWith(topicPath, subscriptionName); return(_topicMessageReceivers.GetOrAdd(key, k => CreateTopicReceiver(topicPath, subscriptionName, filter))); }
/// <summary> /// Fetches a list of raw data information for the <paramref name="entity"/> identified by <paramref name="uuids"/> and filtered by <paramref name="filter"/>. /// Either <paramref name="uuids" /> or <paramref name="filter"/> must have a value. /// </summary> /// <param name="entity">The <see cref="RawDataEntityDto"/> the raw data information should be fetched for.</param> /// <param name="uuids">The list of value uuids the data information should be fetched for.</param> /// <param name="filter">A condition used to filter the result.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> /// <exception cref="InvalidOperationException">No uuids and no filter was specified.</exception> /// <exception cref="OperationNotSupportedOnServerException">An attribute filter for raw data is not supported by this server.</exception> public async Task <RawDataInformationDto[]> ListRawData(RawDataEntityDto entity, string[] uuids, IFilterCondition filter = null, CancellationToken cancellationToken = default) { if (uuids == null && filter == null) { throw new InvalidOperationException("Either a filter or at least one uuid must be specified."); } if (filter != null) { var featureMatrix = await GetFeatureMatrixInternal(FetchBehavior.FetchIfNotCached, cancellationToken).ConfigureAwait(false); if (!featureMatrix.SupportsRawDataAttributeFilter) { throw new OperationNotSupportedOnServerException( "An attribute filter for raw data is not supported by this server.", RawDataServiceFeatureMatrix.RawDataAttributeFilterMinVersion, featureMatrix.CurrentInterfaceVersion); } } return(uuids != null ? await ListRawDataByUuidList(entity, uuids, filter, cancellationToken).ConfigureAwait(false) : await ListRawDataForAllEntities(entity, filter, cancellationToken).ConfigureAwait(false)); }
public INimbusMessageReceiver GetTopicReceiver(string topicPath, string subscriptionName, IFilterCondition filter) { var subscription = new Subscription(topicPath, subscriptionName); return(_container.ResolveWithOverrides <InProcessSubscriptionReceiver>(subscription)); }
/// <summary> /// Adds a new condition to the list of conditions. /// </summary> /// <param name="condition">The <see cref="IFilterCondition"/> condition.</param> public void Add(IFilterCondition condition) { Conditions.Add(condition); }