Пример #1
0
        /// <summary>
        /// Поиск номенклатур по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <param name="option">Опции поиска</param>
        /// <returns>Коллекция найденных номенклатур</returns>
        public IEnumerable <Nomenclature> GetNomenclaturesByName(string name, CatalogSearchOption option)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var nomenclatures = Enumerable.Empty <Nomenclature>();

            switch (option)
            {
            case CatalogSearchOption.Equals:
                nomenclatures = Nomenclatures.Where(n => n.Name.Equals(name));
                break;

            case CatalogSearchOption.Contains:
                nomenclatures = Nomenclatures.Where(n => n.Name.Contains(name));
                break;

            case CatalogSearchOption.StartsWith:
                nomenclatures = Nomenclatures.Where(n => n.Name.StartsWith(name));
                break;

            case CatalogSearchOption.EndsWith:
                nomenclatures = Nomenclatures.Where(n => n.Name.EndsWith(name));
                break;

            default:
                break;
            }

            return(nomenclatures);
        }
Пример #2
0
        /// <summary>
        /// Поиск характеристик по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <param name="option">Опции поиска</param>
        /// <returns>Коллекция найденных характеристик</returns>
        public IEnumerable <Characteristic> GetCharacteristicsByName(string name, CatalogSearchOption option)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var result = Enumerable.Empty <Characteristic>();

            switch (option)
            {
            case CatalogSearchOption.Equals:
                result = characteristics.Where(c => c.Name.Equals(name));
                break;

            case CatalogSearchOption.Contains:
                result = characteristics.Where(c => c.Name.Contains(name));
                break;

            case CatalogSearchOption.StartsWith:
                result = characteristics.Where(c => c.Name.StartsWith(name));
                break;

            case CatalogSearchOption.EndsWith:
                result = characteristics.Where(c => c.Name.EndsWith(name));
                break;

            default:
                break;
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Поиск папок по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <param name="option">Опции поиска</param>
        /// <returns>Коллекция найденных папок</returns>
        internal IEnumerable <Folder> GetFoldersByName(string name, CatalogSearchOption option)
        {
            var folders = new List <Folder>();

            foreach (var folder in Folders)
            {
                folders.AddRange(folder.GetFoldersByName(name, option));
            }

            switch (option)
            {
            case CatalogSearchOption.Equals:
                folders.AddRange(Folders.Where(f => f.Name.Equals(name)));
                break;

            case CatalogSearchOption.Contains:
                folders.AddRange(Folders.Where(f => f.Name.Contains(name)));
                break;

            case CatalogSearchOption.StartsWith:
                folders.AddRange(Folders.Where(f => f.Name.StartsWith(name)));
                break;

            case CatalogSearchOption.EndsWith:
                folders.AddRange(Folders.Where(f => f.Name.EndsWith(name)));
                break;

            default:
                break;
            }

            return(folders);
        }
Пример #4
0
        /// <summary>
        /// Поиск папок по имени
        /// </summary>
        /// <param name="name">Искомое имя</param>
        /// <param name="option">Опции поиска</param>
        /// <returns>Коллекция найденных папок</returns>
        public IEnumerable <Folder> GetFoldersByName(string name, CatalogSearchOption option)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            var folders = new List <Folder>();

            foreach (var folder in Folders)
            {
                folders.AddRange(folder.GetFoldersByName(name, option));
            }

            switch (option)
            {
            case CatalogSearchOption.Equals:
                folders.AddRange(Folders.Where(f => f.Name.Equals(name)));
                break;

            case CatalogSearchOption.Contains:
                folders.AddRange(Folders.Where(f => f.Name.Contains(name)));
                break;

            case CatalogSearchOption.StartsWith:
                folders.AddRange(Folders.Where(f => f.Name.StartsWith(name)));
                break;

            case CatalogSearchOption.EndsWith:
                folders.AddRange(Folders.Where(f => f.Name.EndsWith(name)));
                break;

            default:
                break;
            }

            return(folders.ToArray());
        }