Exemplo n.º 1
0
        /// <summary>
        /// Supported document extensions that are to be searched.
        /// </summary>
        /// <param name="supportedDocuments">The supported documents.</param>
        public SupportedDocumentExtension(SupportedDocuments supportedDocuments)
        {
            _searchPatterns     = new Dictionary <Engine.SupportedDocuments, List <string> >();
            _supportedDocuments = supportedDocuments;

            // Add default extensions.
            AddDefaultExtensions();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get the formatted search patterns.
        /// </summary>
        /// <param name="supportedDocuments">The supported document format.</param>
        /// <returns>Semi-colon (;) seperated aearch patters.</returns>
        public string GetFormattedSearchPatterns(SupportedDocuments supportedDocuments)
        {
            StringBuilder builder = new StringBuilder();

            // If html has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Html))
            {
                List <string> html = _searchPatterns[SupportedDocuments.Html];
                foreach (string item in html)
                {
                    builder.Append(item + ";");
                }
            }

            // If pdf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Pdf))
            {
                List <string> pdf = _searchPatterns[SupportedDocuments.Pdf];
                foreach (string item in pdf)
                {
                    builder.Append(item + ";");
                }
            }

            // If rtf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Rtf))
            {
                List <string> rtf = _searchPatterns[SupportedDocuments.Rtf];
                foreach (string item in rtf)
                {
                    builder.Append(item + ";");
                }
            }

            // If txt has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Txt))
            {
                List <string> txt = _searchPatterns[SupportedDocuments.Txt];
                foreach (string item in txt)
                {
                    builder.Append(item + ";");
                }
            }

            // If xml has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Xml))
            {
                List <string> xml = _searchPatterns[SupportedDocuments.Xml];
                foreach (string item in xml)
                {
                    builder.Append(item + ";");
                }
            }

            // If docx has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Docx))
            {
                List <string> docx = _searchPatterns[SupportedDocuments.Docx];
                foreach (string item in docx)
                {
                    builder.Append(item + ";");
                }
            }

            // Return the pattern.
            return(builder.ToString().TrimEnd(new char[] { ';' }));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a collection of search patterns to the document.
        /// </summary>
        /// <param name="supportedDocuments">The supported document format.</param>
        /// <param name="searchPatterns">The list of search patterns.</param>
        public void AddSearchPatterns(SupportedDocuments supportedDocuments, string[] searchPatterns)
        {
            // If html has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Html))
            {
                List <string> html = _searchPatterns[SupportedDocuments.Html];
                foreach (string item in searchPatterns)
                {
                    html.Add(item);
                }
            }

            // If pdf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Pdf))
            {
                List <string> pdf = _searchPatterns[SupportedDocuments.Pdf];
                foreach (string item in searchPatterns)
                {
                    pdf.Add(item);
                }
            }

            // If rtf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Rtf))
            {
                List <string> rtf = _searchPatterns[SupportedDocuments.Rtf];
                foreach (string item in searchPatterns)
                {
                    rtf.Add(item);
                }
            }

            // If txt has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Txt))
            {
                List <string> txt = _searchPatterns[SupportedDocuments.Txt];
                foreach (string item in searchPatterns)
                {
                    txt.Add(item);
                }
            }

            // If xml has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Xml))
            {
                List <string> xml = _searchPatterns[SupportedDocuments.Xml];
                foreach (string item in searchPatterns)
                {
                    xml.Add(item);
                }
            }

            // If docx has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Docx))
            {
                List <string> docx = _searchPatterns[SupportedDocuments.Docx];
                foreach (string item in searchPatterns)
                {
                    docx.Add(item);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Remove a collection of search patterns for the document.
        /// </summary>
        /// <param name="supportedDocuments">The supported document format.</param>
        /// <param name="searchPatterns">The list of search patterns.</param>
        public void RemoveSearchPatterns(SupportedDocuments supportedDocuments, string[] searchPatterns = null)
        {
            // If html has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Html))
            {
                List <string> html = _searchPatterns[SupportedDocuments.Html];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        html.Remove(item);
                    }
                }
                else
                {
                    html.Clear();
                }
            }

            // If pdf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Pdf))
            {
                List <string> pdf = _searchPatterns[SupportedDocuments.Pdf];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        pdf.Remove(item);
                    }
                }
                else
                {
                    pdf.Clear();
                }
            }

            // If rtf has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Rtf))
            {
                List <string> rtf = _searchPatterns[SupportedDocuments.Rtf];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        rtf.Remove(item);
                    }
                }
                else
                {
                    rtf.Clear();
                }
            }

            // If txt has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Txt))
            {
                List <string> txt = _searchPatterns[SupportedDocuments.Txt];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        txt.Remove(item);
                    }
                }
                else
                {
                    txt.Clear();
                }
            }

            // If xml has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Xml))
            {
                List <string> xml = _searchPatterns[SupportedDocuments.Xml];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        xml.Remove(item);
                    }
                }
                else
                {
                    xml.Clear();
                }
            }

            // If docx has been selected.
            if (supportedDocuments.HasFlag(SupportedDocuments.Docx))
            {
                List <string> docx = _searchPatterns[SupportedDocuments.Docx];
                if (searchPatterns != null)
                {
                    foreach (string item in searchPatterns)
                    {
                        docx.Remove(item);
                    }
                }
                else
                {
                    docx.Clear();
                }
            }
        }