Represents a snippet extraction rule.
        /// <summary>
        /// Creates a new instance of <see cref="ISnippetExtractor"/> according to the snippet extraction rule.
        /// </summary>
        /// <param name="snippetExtractionRule">The snippet extraction rule.</param>
        /// <returns>The matching snippet extractor.</returns>
        public ISnippetExtractor CreateExtractor(SnippetExtractionRule snippetExtractionRule)
        {
            // Return null if the extraction rule is null
            if (null == snippetExtractionRule)
            {
                return null;
            }

            // Lookup factory in loaded extractor factories
            Func<ISnippetExtractor> matchingExtractorFactory;
            if (loadedExtractorFactories.TryGetValue(snippetExtractionRule.Language, out matchingExtractorFactory))
            {
                // Create instance from the matching extractor factory
                return matchingExtractorFactory();
            }

            // Create instance from default extractor factory
            return this.defaultExtractorFactory();
        }
        /// <summary>
        /// Creates a new instance of <see cref="ISnippetExtractor"/> according to the snippet extraction rule.
        /// </summary>
        /// <param name="snippetExtractionRule">The snippet extraction rule.</param>
        /// <returns>The matching snippet extractor.</returns>
        public ISnippetExtractor CreateExtractor(SnippetExtractionRule snippetExtractionRule)
        {
            // Return null if the extraction rule is null
            if (null == snippetExtractionRule)
            {
                return null;
            }

            // Initialize the proper extracted depending on the language
            switch (snippetExtractionRule.Language)
            {
                case "csharp":
                    return new CSharpSnippetExtractor(this.ExtractSourceDirectories(this.CsprojFile));
                case "xml":
                    return new XmlSnippetExtractor(this.ExtractSourceDirectories(this.CsprojFile));
                default:
                    return new DefaultSnippetExtractor(this.ExtractSourceDirectories(this.CsprojFile));
            }
        }
示例#3
0
        /// <summary>
        /// Creates a new instance of <see cref="ISnippetExtractor"/> according to the snippet extraction rule.
        /// </summary>
        /// <param name="snippetExtractionRule">The snippet extraction rule.</param>
        /// <returns>The matching snippet extractor.</returns>
        public ISnippetExtractor CreateExtractor(SnippetExtractionRule snippetExtractionRule)
        {
            // Return null if the extraction rule is null
            if (null == snippetExtractionRule)
            {
                return(null);
            }

            // Lookup factory in loaded extractor factories
            Func <ISnippetExtractor> matchingExtractorFactory;

            if (loadedExtractorFactories.TryGetValue(snippetExtractionRule.Language, out matchingExtractorFactory))
            {
                // Create instance from the matching extractor factory
                return(matchingExtractorFactory());
            }

            // Create instance from default extractor factory
            return(this.defaultExtractorFactory());
        }