Represents a snippet extraction rule.
Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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;
            }

            // 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));
            }
        }
Ejemplo n.º 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());
        }