Пример #1
0
        public IEnumerable <Element> GetElements(Path packagePath, Func <Element, bool> filter, string filterName, bool recursive = false)
        {
            var package = GetPackage(packagePath);
            IEnumerable <Element> elements = null;

            if (recursive)
            {
                var p = FromEaPackage(package);
                elements = p.GetElementsRecursively();
            }
            else
            {
                EA.Package p = GetPackage(packagePath);
                elements = p.Elements
                           .Cast <EA.Element>()
                           .Select(CreateElement);
            }
            var  filtered    = elements.Where(filter);
            File file        = FileNames.GetElementsFiltered(_folder, packagePath, filterName);
            var  elementList = new ElementList {
                Elements = filtered.ToList()
            };

            _jsonSerializer.Value.SerializeToFile(elementList, file.AbsolutePath);
            return(filtered);
        }
Пример #2
0
        public IEnumerable <Element> GetElements(Path packagePath, Func <Element, bool> filter, string filterName, bool recursive = false)
        {
            if (_elementsByFilterName.ContainsKey(filterName))
            {
                return(_elementsByFilterName[filterName]);
            }
            var file = FileNames.GetElementsFiltered(_folder, packagePath, filterName);

            if (file.Exists())
            {
                var elementList = _jsonSerializer.Value.DeserializeFromFile <ElementList>(file.AbsolutePath);
                _elementsByFilterName[filterName] = elementList.Elements;
                return(elementList.Elements);
            }
            return(null);
        }