コード例 #1
0
        public AuditConfig IgnoreProperty(Expression <Func <PropertyEntry, bool> > lambda)
        {
            var func = lambda.Compile();

            PropertyFilters.Add((entity, property) => func(property));
            return(this);
        }
コード例 #2
0
        private static void SetPropertyFilters(SearchFilters filters, PropertyFilters propertyFilters)
        {
            if (propertyFilters == null)
            {
                return;
            }

            SetPropertyFilters(filters, propertyFilters.Armour);
            SetPropertyFilters(filters, propertyFilters.Weapon);
            SetPropertyFilters(filters, propertyFilters.Map);
            SetPropertyFilters(filters, propertyFilters.Misc);
        }
コード例 #3
0
 /// <summary>
 /// Resets this instance.
 /// </summary>
 public override void Reset()
 {
     IsLoaded           = false;
     SelectedDataSet    = DataSetsCollectionView.FirstOrDefault();
     SelectedProperty   = PropertyFilters.FirstOrDefault();
     PropertyFilterText = string.Empty;
     IsLoaded           = true;
     GetPage();
     if (CollectionItems.Count > 0)
     {
         CollectionItems.MoveCurrentToFirst();
     }
 }
コード例 #4
0
        public AuditConfig IgnoreProperty <Entity>(Expression <Func <Entity, object> > lambda)
        {
            var body = lambda.Body as MemberExpression;

            if (body == null)
            {
                UnaryExpression ubody = (UnaryExpression)lambda.Body;
                body = ubody.Operand as MemberExpression;
            }

            var propertyName = body.Member.Name;

            PropertyFilters.Add((entity, property) =>
                                entity.Metadata.GetTableName() == typeof(Entity).Name && property.Metadata.GetColumnName() == propertyName
                                );
            return(this);
        }
コード例 #5
0
 public async Task <IEnumerable <VHost> > GetVirtualHosts(QueryOrder sorting = QueryOrder.Ascending, Expression <Func <VHost, object> > sortSelector = null, PropertyFilters <VHost> filters = null, CancellationToken cancellationToken = default)
 {
     return(await GetList(RabbitMQEndPoints.GetVirtualHosts, sorting, sortSelector, filters, cancellationToken));
 }
コード例 #6
0
        public async Task <IEnumerable <Binding> > GetExchangeBindings(string sourceExchangeName, string destinationExchangeName, string virtualHost = null, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <Binding, object> > sortSelector = null, PropertyFilters <Binding> filters = null, CancellationToken cancellationToken = default)
        {
            if (sourceExchangeName == null)
            {
                throw new ArgumentNullException(nameof(sourceExchangeName));
            }
            if (destinationExchangeName == null)
            {
                throw new ArgumentNullException(nameof(destinationExchangeName));
            }

            return(await GetList(string.Format(RabbitMQEndPoints.GetBindingForExchanges, ConvertVirtualHost(virtualHost), sourceExchangeName, destinationExchangeName), sorting, sortSelector, filters, cancellationToken));
        }
コード例 #7
0
        private static IQueryable <Apartment> ApplyFilters(IQueryable <Apartment>?dbSet, PropertyFilters propertyFilters)
        {
            var priceAsNullable = propertyFilters.PricePerMonth.Match(s => (decimal?)s, _ => null);
            var rooms           = propertyFilters.NumberOfRooms.Match(s => (int?)s, _ => null);
            var size            = propertyFilters.FloorArea.Match(s => (int?)s, _ => null);

            return(dbSet
                   .Where(a => (propertyFilters.IncludeRented || !a.IsRented) && (priceAsNullable == null || a.PricePerMonth == priceAsNullable.Value) && (rooms == null || a.NumberOfRooms == rooms.Value) && (size == null || a.FloorArea == size.Value)));
        }
コード例 #8
0
        public async Task <TradeSearchResult <string> > Search(Item item, PropertyFilters propertyFilters = null, ModifierFilters modifierFilters = null)
        {
            try
            {
                logger.LogInformation("Querying Trade API.");

                var request = new QueryRequest();
                SetPropertyFilters(request.Query.Filters, propertyFilters);
                SetModifierFilters(request.Query.Stats, modifierFilters);

                // Auto Search 5+ Links
                var highestCount = item.Sockets
                                   .GroupBy(x => x.Group)
                                   .Select(x => x.Count())
                                   .OrderByDescending(x => x)
                                   .FirstOrDefault();
                if (highestCount >= 5)
                {
                    request.Query.Filters.SocketFilters.Filters.Links = new SocketFilterOption()
                    {
                        Min = highestCount,
                    };
                }

                if (item.Metadata.Category == Category.ItemisedMonster)
                {
                    if (!string.IsNullOrEmpty(item.Metadata.Name))
                    {
                        request.Query.Term = item.Metadata.Name;
                    }
                    else if (!string.IsNullOrEmpty(item.Metadata.Type))
                    {
                        request.Query.Type = item.Metadata.Type;
                    }
                }
                else if (item.Metadata.Rarity == Rarity.Unique)
                {
                    request.Query.Name = item.Metadata.Name;
                    request.Query.Type = item.Metadata.Type;
                    request.Query.Filters.TypeFilters.Filters.Rarity = new SearchFilterOption("Unique");
                }
                else if (item.Metadata.Rarity == Rarity.Prophecy)
                {
                    request.Query.Name = item.Metadata.Name;
                }
                else
                {
                    if (string.IsNullOrEmpty(request.Query.Filters.TypeFilters.Filters.Category?.Option))
                    {
                        request.Query.Type = item.Metadata.Type;
                    }
                    request.Query.Filters.TypeFilters.Filters.Rarity = new SearchFilterOption("nonunique");
                }

                if (item.Properties.AlternateQuality)
                {
                    request.Query.Term = item.Original.Name;
                }

                if (item.Properties.MapTier > 0)
                {
                    request.Query.Filters.MapFilters.Filters.MapTier = new SearchFilterValue(item.Properties.MapTier, item.Properties.MapTier);
                }

                var uri      = new Uri($"{gameLanguageProvider.Language.PoeTradeApiBaseUrl}search/{settings.LeagueId}");
                var json     = JsonSerializer.Serialize(request, poeTradeClient.Options);
                var body     = new StringContent(json, Encoding.UTF8, "application/json");
                var response = await poeTradeClient.HttpClient.PostAsync(uri, body);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStreamAsync();

                    return(await JsonSerializer.DeserializeAsync <TradeSearchResult <string> >(content, poeTradeClient.Options));
                }
                else
                {
                    var responseMessage = await response?.Content?.ReadAsStringAsync();

                    logger.LogWarning("Querying failed: {responseCode} {responseMessage}", response.StatusCode, responseMessage);
                    logger.LogWarning("Uri: {uri}", uri);
                    logger.LogWarning("Query: {query}", json);
                }
            }
            catch (Exception ex)
            {
                logger.LogWarning(ex, "Exception thrown while querying trade api.");
            }

            return(null);
        }
コード例 #9
0
 public async Task <IEnumerable <RabbitMqConnection> > GetConnections(string virtualHost = null, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <RabbitMqConnection, object> > sortSelector = null, PropertyFilters <RabbitMqConnection> filters = null, CancellationToken cancellationToken = default)
 {
     return(await GetList(virtualHost, RabbitMQEndPoints.GetConnections, RabbitMQEndPoints.GetConnectionsWithVHost, sorting, sortSelector, filters, cancellationToken));
 }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Type != null)
         {
             hashCode = hashCode * 59 + Type.GetHashCode();
         }
         if (ImportMode != null)
         {
             hashCode = hashCode * 59 + ImportMode.GetHashCode();
         }
         if (AclHandling != null)
         {
             hashCode = hashCode * 59 + AclHandling.GetHashCode();
         }
         if (PackageRoots != null)
         {
             hashCode = hashCode * 59 + PackageRoots.GetHashCode();
         }
         if (PackageFilters != null)
         {
             hashCode = hashCode * 59 + PackageFilters.GetHashCode();
         }
         if (PropertyFilters != null)
         {
             hashCode = hashCode * 59 + PropertyFilters.GetHashCode();
         }
         if (TempFsFolder != null)
         {
             hashCode = hashCode * 59 + TempFsFolder.GetHashCode();
         }
         if (UseBinaryReferences != null)
         {
             hashCode = hashCode * 59 + UseBinaryReferences.GetHashCode();
         }
         if (AutoSaveThreshold != null)
         {
             hashCode = hashCode * 59 + AutoSaveThreshold.GetHashCode();
         }
         if (CleanupDelay != null)
         {
             hashCode = hashCode * 59 + CleanupDelay.GetHashCode();
         }
         if (FileThreshold != null)
         {
             hashCode = hashCode * 59 + FileThreshold.GetHashCode();
         }
         if (MEGA_BYTES != null)
         {
             hashCode = hashCode * 59 + MEGA_BYTES.GetHashCode();
         }
         if (UseOffHeapMemory != null)
         {
             hashCode = hashCode * 59 + UseOffHeapMemory.GetHashCode();
         }
         if (DigestAlgorithm != null)
         {
             hashCode = hashCode * 59 + DigestAlgorithm.GetHashCode();
         }
         if (MonitoringQueueSize != null)
         {
             hashCode = hashCode * 59 + MonitoringQueueSize.GetHashCode();
         }
         if (PathsMapping != null)
         {
             hashCode = hashCode * 59 + PathsMapping.GetHashCode();
         }
         if (StrictImport != null)
         {
             hashCode = hashCode * 59 + StrictImport.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     ImportMode == other.ImportMode ||
                     ImportMode != null &&
                     ImportMode.Equals(other.ImportMode)
                 ) &&
                 (
                     AclHandling == other.AclHandling ||
                     AclHandling != null &&
                     AclHandling.Equals(other.AclHandling)
                 ) &&
                 (
                     PackageRoots == other.PackageRoots ||
                     PackageRoots != null &&
                     PackageRoots.Equals(other.PackageRoots)
                 ) &&
                 (
                     PackageFilters == other.PackageFilters ||
                     PackageFilters != null &&
                     PackageFilters.Equals(other.PackageFilters)
                 ) &&
                 (
                     PropertyFilters == other.PropertyFilters ||
                     PropertyFilters != null &&
                     PropertyFilters.Equals(other.PropertyFilters)
                 ) &&
                 (
                     TempFsFolder == other.TempFsFolder ||
                     TempFsFolder != null &&
                     TempFsFolder.Equals(other.TempFsFolder)
                 ) &&
                 (
                     UseBinaryReferences == other.UseBinaryReferences ||
                     UseBinaryReferences != null &&
                     UseBinaryReferences.Equals(other.UseBinaryReferences)
                 ) &&
                 (
                     AutoSaveThreshold == other.AutoSaveThreshold ||
                     AutoSaveThreshold != null &&
                     AutoSaveThreshold.Equals(other.AutoSaveThreshold)
                 ) &&
                 (
                     CleanupDelay == other.CleanupDelay ||
                     CleanupDelay != null &&
                     CleanupDelay.Equals(other.CleanupDelay)
                 ) &&
                 (
                     FileThreshold == other.FileThreshold ||
                     FileThreshold != null &&
                     FileThreshold.Equals(other.FileThreshold)
                 ) &&
                 (
                     MEGA_BYTES == other.MEGA_BYTES ||
                     MEGA_BYTES != null &&
                     MEGA_BYTES.Equals(other.MEGA_BYTES)
                 ) &&
                 (
                     UseOffHeapMemory == other.UseOffHeapMemory ||
                     UseOffHeapMemory != null &&
                     UseOffHeapMemory.Equals(other.UseOffHeapMemory)
                 ) &&
                 (
                     DigestAlgorithm == other.DigestAlgorithm ||
                     DigestAlgorithm != null &&
                     DigestAlgorithm.Equals(other.DigestAlgorithm)
                 ) &&
                 (
                     MonitoringQueueSize == other.MonitoringQueueSize ||
                     MonitoringQueueSize != null &&
                     MonitoringQueueSize.Equals(other.MonitoringQueueSize)
                 ) &&
                 (
                     PathsMapping == other.PathsMapping ||
                     PathsMapping != null &&
                     PathsMapping.Equals(other.PathsMapping)
                 ) &&
                 (
                     StrictImport == other.StrictImport ||
                     StrictImport != null &&
                     StrictImport.Equals(other.StrictImport)
                 ));
        }
コード例 #12
0
        public async Task <IEnumerable <Apartment> > GetAll(int?floorArea, decimal?pricePerMonth, int?numberOfRooms, CancellationToken cancellationToken)
        {
            var filters = new PropertyFilters(ToOption(floorArea), ToOption(pricePerMonth), ToOption(numberOfRooms), await this.IsAdminOrRealtor(cancellationToken));

            return(await this.mediator.Send(new GetApartments(filters), cancellationToken));
        }
コード例 #13
0
 private async Task <IEnumerable <T> > GetList <T>(string endpoint, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <T, object> > sortSelector = null, PropertyFilters <T> filters = null, CancellationToken cancellationToken = default)
 {
     return(await Get <List <T> >(_queryBuilder.Build(endpoint, sorting, sortSelector, filters), cancellationToken));
 }
コード例 #14
0
        private async Task <IEnumerable <T> > GetList <T>(string virtualHost, string uriWithoutVHost, string uriWithVHost, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <T, object> > sortSelector = null, PropertyFilters <T> filters = null, CancellationToken cancellationToken = default)
        {
            var endPoint = GetEndpointForVHost(uriWithoutVHost, uriWithVHost, virtualHost);

            return(await GetList(endPoint, sorting, sortSelector, filters, cancellationToken));
        }
コード例 #15
0
 public AuditConfig IgnoreProperty(string tableName, string propertyName)
 {
     PropertyFilters.Add((entity, property) => entity.Metadata.GetTableName() == tableName && property.Metadata.GetColumnName() == propertyName);
     return(this);
 }
コード例 #16
0
        public async Task <IEnumerable <Permission> > GetPermissions(string virtualHost, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <Permission, object> > sortSelector = null, PropertyFilters <Permission> filters = null, CancellationToken cancellationToken = default)
        {
            if (virtualHost == null)
            {
                throw new ArgumentNullException(nameof(virtualHost));
            }

            return(await GetList(string.Format(RabbitMQEndPoints.GetPermissions, ConvertVirtualHost(virtualHost)), sorting, sortSelector, filters, cancellationToken));
        }
コード例 #17
0
 public async Task <IEnumerable <User> > GetUsersWithoutPermissions(QueryOrder sorting = QueryOrder.Ascending, Expression <Func <User, object> > sortSelector = null, PropertyFilters <User> filters = null, CancellationToken cancellationToken = default)
 {
     return(await GetList(RabbitMQEndPoints.GetUsersWithoutPermissions, sorting, sortSelector, filters, cancellationToken));
 }
コード例 #18
0
ファイル: LogFilter.cs プロジェクト: lippy/JsonObfuscatetest
 public ILogFilter <T> Ignore(Expression <Func <T, object> > func)
 {
     PropertyFilters.Add(func);
     return(this);
 }
コード例 #19
0
 /// <summary>
 /// Add a filter to identify properties that should be traversed.
 /// </summary>
 /// <param name="filter">A filter for a <see cref="PropertyInfo"/>.</param>
 /// <returns>The current <see cref="ValidatorBuilder{TState}"/>.</returns>
 public ValidatorBuilder <TState> AddPropertyFilter(Func <PropertyInfo, bool> filter)
 {
     PropertyFilters.Add(filter);
     return(this);
 }
コード例 #20
0
        public string Build <T>(string endPoint, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <T, object> > sortSelector = null, PropertyFilters <T> propertyFilters = null)
        {
            var dict = new Dictionary <string, string>();

            if (sorting == QueryOrder.Descending)
            {
                dict.Add("sortReverse", "true");
            }

            if (sortSelector != null)
            {
                dict.Add("sort", GetSortingKey(sortSelector));
            }

            if (propertyFilters != null)
            {
                var filters = propertyFilters.GetProperties().ToList();

                if (filters.Any())
                {
                    dict.Add("columns", string.Join(",", filters.Select(GetSortingKey).ToArray()));
                }
            }

            return(endPoint + (dict.Any() ? "?" + string.Join("&", dict.Select(x => x.Key + "=" + x.Value).ToArray()) : string.Empty));
        }
コード例 #21
0
        public async Task <IEnumerable <RabbitMqChannel> > GetChannelsForConnection(string connectionName, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <RabbitMqChannel, object> > sortSelector = null, PropertyFilters <RabbitMqChannel> filters = null, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrWhiteSpace(connectionName))
            {
                throw new ArgumentNullException(nameof(connectionName));
            }

            return(await GetList(string.Format(RabbitMQEndPoints.GetChannelsForConnection, connectionName), sorting, sortSelector, filters, cancellationToken));
        }
コード例 #22
0
        public async Task <IEnumerable <Binding> > GetExchangeBindings(string exchangeName, ExchangeBindingType type, string virtualHost = null, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <Binding, object> > sortSelector = null, PropertyFilters <Binding> filters = null, CancellationToken cancellationToken = default)
        {
            var uriTemplate = type == ExchangeBindingType.Source ? RabbitMQEndPoints.GetBindingForSourceExchange : RabbitMQEndPoints.GetBindingForDestinationExchange;
            var uri         = string.Format(uriTemplate, ConvertVirtualHost(virtualHost), exchangeName);

            return(await GetList(uri, sorting, sortSelector, filters, cancellationToken));
        }
コード例 #23
0
 async Task <IEnumerable <Apartment> > IApartmentRepository.GetAll(PropertyFilters propertyFilters, CancellationToken token)
 {
     return(await ApplyFilters(this.context.Apartments, propertyFilters).OrderBy(a => a.Name).ToArrayAsync(token));
 }
コード例 #24
0
        public async Task <IEnumerable <Binding> > GetQueueBindings(string queueName, string virtualHost = null, QueryOrder sorting = QueryOrder.Ascending, Expression <Func <Binding, object> > sortSelector = null, PropertyFilters <Binding> filters = null, CancellationToken cancellationToken = default)
        {
            var uri = string.Format(RabbitMQEndPoints.GetQueueBindings, ConvertVirtualHost(virtualHost), queueName);

            return(await GetList(uri, sorting, sortSelector, filters, cancellationToken));
        }
コード例 #25
0
        public async Task ShouldRetrieveAListOfAllNodes()
        {
            var httpClient = new HttpClient {
                BaseAddress = TestConfiguration.Uri
            };
            var client = new RabbitMQAdminClient(httpClient, TestConfiguration.UserName, TestConfiguration.Password);

            var nodes = await client.GetNodes(QueryOrder.Ascending, node => node.Name, PropertyFilters <RabbitMqNode> .Build().AddFilter(x => x.Name).AddFilter(x => x.Contexts), CancellationToken.None);

            nodes.Should().NotBeNull();
        }
コード例 #26
0
 public GetApartments(PropertyFilters propertyFilters)
 {
     this.PropertyFilters = propertyFilters;
 }