Example #1
0
        private async Task ProcessIncludes(List <IEntity> results, CancellationToken ct)
        {
            if (!Includes.Any())
            {
                return;
            }

            //TODO: optimize / parallel processing
            foreach (var propertyDefinition in Includes)
            {
                var targetEntityDefinition =
                    (IEntityDefinition)propertyDefinition.PropertyType.GetTargetValueType(propertyDefinition);

                var foreignIds = results
                                 .Select(x => x[propertyDefinition.Name])
                                 .Where(x => x != null)
                                 .Cast <IEntity>()
                                 .Select(x => _repository.GetDocumentId(targetEntityDefinition, x.Id))
                                 .Distinct();

                var foreignQuery = new DocumentDbQuery(_repository, targetEntityDefinition)
                                   .Add(Criterion.In(MetaConstants.IdProperty, foreignIds.Cast <object>().ToArray()));
                var foreignEntities = (await foreignQuery.ToEnumerable <IEntity>(ct)).ToDictionary(x => x.Id);

                results.ForEach(x =>
                {
                    var foreignId = ((IEntity)x[propertyDefinition.Name])?.Id;
                    if (foreignId != null && foreignEntities.ContainsKey(foreignId))
                    {
                        x[propertyDefinition.Name] = foreignEntities[foreignId];
                    }
                });
            }
        }
Example #2
0
        public bool ContainsNode(string name)
        {
            if (Name == name)
            {
                return(true);
            }

            return(Includes.Any(node => node.ContainsNode(name)));
        }
Example #3
0
        public IQueryable <TEntity> FindAll()
        {
            var set = Ds.Context.Set <TEntity>().AsQueryable();

            if (Includes != null && Includes.Any())
            {
                set = set.Include(Includes.ToArray());
            }

            if (Filter != null)
            {
                set = set.Where(Filter);
            }
            return(set);
        }
Example #4
0
 private bool IsMatch(string file)
 {
     if (Exclusive)
     {
         if (!Includes.Any(include => Regex.IsMatch(file, include)))
         {
             return(false);
         }
     }
     if (Filtered)
     {
         return(Excludes.All(exclude => !Regex.IsMatch(file, exclude)));
     }
     return(true);
 }
Example #5
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine(new string('-', 20));
            sb.AppendLine($"Name: {Name}");

            if (Version != null)
            {
                sb.AppendLine($"Version: {Version}");
            }

            if (!string.IsNullOrWhiteSpace(Description))
            {
                sb.AppendLine($"Description: {Description}");
            }

            if (Authors != null && Authors.Any())
            {
                sb.AppendLine("Authors:");
                foreach (var i in Authors)
                {
                    sb.AppendLine($" - {i}");
                }
            }

            if (Date != null)
            {
                sb.AppendLine($"Date: {DateTime:F}");
            }

            if (Includes.Any())
            {
                sb.AppendLine("Includes:");
                foreach (var i in Includes)
                {
                    sb.AppendLine($" - '{i.Path}' => '{i.Mount}'");
                }
            }

            if (!string.IsNullOrWhiteSpace(Main))
            {
                sb.AppendLine($"Main: {Main}");
            }

            sb.AppendLine(new string('-', 20));
            return(sb.ToString());
        }
        public TreeTextRange Translate(DocumentRange documentRange)
        {
            if (!documentRange.IsValid())
            {
                return(TreeTextRange.InvalidRange);
            }
            if (!SourceFile.IsValid())
            {
                return(TreeTextRange.InvalidRange);
            }
            if (!FileLikeNode.IsValid())
            {
                return(TreeTextRange.InvalidRange);
            }

            if (documentRange.Document != SourceFile.Document)
            {
                // That document might appear among the includes
                var rangeFromIncludes = Includes
                                        .Select(include => include.DocumentRangeTranslator.Translate(documentRange))
                                        .Where(textRange => textRange.IsValid())
                                        // Allow FirstOrDefault to return null
                                        .Select <TreeTextRange, TreeTextRange?>(it => it)
                                        .FirstOrDefault();
                return(rangeFromIncludes ?? TreeTextRange.InvalidRange);
            }

            // The range is in the same document as the source file we are responsible for,
            // so we have no choice but to handle the request ourselves
            (int documentStartOffset, int documentEndOffset) = documentRange.TextRange;
            var rootStartOffset = FileLikeNode.GetTreeStartOffset();

            // No includes, tree and document are matching
            if (!Includes.Any())
            {
                return(new TreeTextRange(rootStartOffset + documentStartOffset, rootStartOffset + documentEndOffset));
            }

            var treeStartOffset = Translate(documentStartOffset);

            if (!treeStartOffset.IsValid())
            {
                return(TreeTextRange.InvalidRange);
            }
            return(TreeTextRange.FromLength(treeStartOffset, documentRange.Length));
        }
Example #7
0
        public bool ShouldRun(TestMeta test)
        {
            Setup();

            bool?run = null;



            if (_nameFilters.ContainsKey(test.UniqueName))
            {
                run = _nameFilters[test.UniqueName];
            }

            if (_nameFilters.ContainsKey(test.Fixture.UniqueName))
            {
                run = _nameFilters[test.Fixture.UniqueName];
            }

            if (_nameFilters.ContainsKey(test.Fixture.Assembly.UniqueName))
            {
                run = _nameFilters[test.Fixture.Assembly.UniqueName];
            }

            if (test.Category.Any(c => _nameFilters.ContainsKey(UniqueCategory(c))))
            {
                run = test.Category
                      .Where(c => _nameFilters.ContainsKey(UniqueCategory(c)))
                      .Select(c => _nameFilters[UniqueCategory(c)])
                      .All(b => b);
            }


            if (!run.HasValue)
            {
                if (!_nameFilters.Any() || (!Includes.Any() && Excludes.Any()))
                {
                    return(true);
                }
                return(false);
            }

            return(run.Value);
        }
        /// <summary>
        ///     Поиск всех вхождений по указанным инклукдам
        /// </summary>
        /// <returns>
        ///     Перечисление путей файлов, подходящих по маске
        ///     к списку инклудов
        /// </returns>
        public IEnumerable <string> Collect()
        {
            var directincludes = Includes.Where(File.Exists).Select(_ => _.NormalizePath()).ToArray();

            foreach (var directinclude in directincludes)
            {
                yield return(directinclude);
            }
            foreach (var root in Roots)
            {
                foreach (var mask in SearchMasks)
                {
                    foreach (var f in
                             Directory.GetFiles(root, mask, SearchOption.AllDirectories)
                             )
                    {
                        var normalized = f.Replace(root, "").Replace("\\", "/");
                        if (Includes.Any())
                        {
                            if (directincludes.Contains(normalized))
                            {
                                continue;
                            }

                            if (!Includes.Any(normalized.Contains))
                            {
                                continue;
                            }
                        }
                        if (Excludes.Any())
                        {
                            if (Excludes.Any(normalized.Contains))
                            {
                                continue;
                            }
                        }
                        yield return(f);
                    }
                }
            }
        }
Example #9
0
 public bool IsMatch(string packageId)
 {
     return(Includes.Any(e => e.IsMatch(packageId)) &&
            !Excludes.Any(e => e.IsMatch(packageId)));
 }
Example #10
0
 internal bool Matches(string str)
 {
     return(Includes.Any(i => i.Matches(str)) && !Excludes.Any(e => e.Matches(str)));
 }
 /// <inheritdoc/>
 public override string ToString()
 {
     return(Includes != null && Includes.Any() ? "include=" + string.Join(",", Includes.Select(p => p.ToString())) : string.Empty);
 }