Creates the proper snippet exctractor depending on the pattern.
Example #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="ProjbookEngine"/>.
        /// </summary>
        /// <param name="csprojFile">Initializes the required <see cref="CsprojFile"/>.</param>
        /// <param name="templateFilePath">Initializes the required <see cref="TemplateFile"/>.</param>
        /// <param name="configFile">Initializes the required <see cref="ConfigFile"/>.</param>
        /// <param name="outputDirectoryPath">Initializes the required <see cref="OutputDirectory"/>.</param>
        public ProjbookEngine(string csprojFile, string templateFilePath, string configFile, string outputDirectoryPath)
        {
            // Data validation
            Ensure.That(() => csprojFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => templateFilePath).IsNotNullOrWhiteSpace();
            Ensure.That(() => configFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => outputDirectoryPath).IsNotNullOrWhiteSpace();
            Ensure.That(File.Exists(csprojFile), string.Format("Could not find '{0}' file", csprojFile)).IsTrue();
            Ensure.That(File.Exists(templateFilePath), string.Format("Could not find '{0}' file", templateFilePath)).IsTrue();
            Ensure.That(File.Exists(configFile), string.Format("Could not find '{0}' file", configFile)).IsTrue();

            // Initialize
            this.CsprojFile = new FileInfo(csprojFile);
            this.TemplateFile = new FileInfo(templateFilePath);
            this.ConfigFile = new FileInfo(configFile);
            this.OutputDirectory = new DirectoryInfo(outputDirectoryPath);
            this.snippetExtractorFactory = new SnippetExtractorFactory(this.CsprojFile);
            this.sectionSplittingIdentifier = Guid.NewGuid().ToString();
            this.regex = new Regex(
                string.Format(@"<!--{0} \[([^\]]*)\]\(([^\)]*)\)-->(.+?)(?=<!--{0} |$)", this.sectionSplittingIdentifier),
                RegexOptions.Compiled | RegexOptions.Singleline);

            // Compute and initialize pdf template
            string templateDirectory = Path.GetDirectoryName(templateFilePath);
            string pdfTemplateFile = string.Format("{0}-pdf{1}", Path.GetFileNameWithoutExtension(templateFilePath), Path.GetExtension(templateFilePath));
            this.TemplateFilePdf = new FileInfo(Path.Combine(templateDirectory, pdfTemplateFile));
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of <see cref="ProjbookEngine"/>.
        /// </summary>
        /// <param name="csprojFile">Initializes the required <see cref="CsprojFile"/>.</param>
        /// <param name="templateFilePath">Initializes the required <see cref="TemplateFile"/>.</param>
        /// <param name="configFile">Initializes the required <see cref="ConfigFile"/>.</param>
        /// <param name="outputDirectoryPath">Initializes the required <see cref="OutputDirectory"/>.</param>
        public ProjbookEngine(string csprojFile, string templateFilePath, string configFile, string outputDirectoryPath)
        {
            // Data validation
            Ensure.That(() => csprojFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => templateFilePath).IsNotNullOrWhiteSpace();
            Ensure.That(() => configFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => outputDirectoryPath).IsNotNullOrWhiteSpace();
            Ensure.That(File.Exists(csprojFile), string.Format("Could not find '{0}' file", csprojFile)).IsTrue();
            Ensure.That(File.Exists(templateFilePath), string.Format("Could not find '{0}' file", templateFilePath)).IsTrue();
            Ensure.That(File.Exists(configFile), string.Format("Could not find '{0}' file", configFile)).IsTrue();

            // Initialize
            this.CsprojFile = new FileInfo(csprojFile);
            this.TemplateFile = new FileInfo(templateFilePath);
            this.ConfigFile = new FileInfo(configFile);
            this.OutputDirectory = new DirectoryInfo(outputDirectoryPath);
            this.snippetExtractorFactory = new SnippetExtractorFactory(this.CsprojFile);

            // Compute and initialize pdf template
            string templateDirectory = Path.GetDirectoryName(templateFilePath);
            string pdfTemplateFile = string.Format("{0}-pdf{1}", Path.GetFileNameWithoutExtension(templateFilePath), Path.GetExtension(templateFilePath));
            this.TemplateFilePdf = new FileInfo(Path.Combine(templateDirectory, pdfTemplateFile));
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of <see cref="ProjbookEngine"/>.
        /// </summary>
        /// <param name="fileSystem">Initializes the required file system abstraction.</param>
        /// <param name="extensionPath">Initializes the required extension path.</param>
        /// <param name="csprojFile">Initializes the required <see cref="CsprojFile"/>.</param>
        /// <param name="indexConfiguration">Initializes the required <see cref="IndexConfiguration"/>.</param>
        /// <param name="outputDirectoryPath">Initializes the required <see cref="OutputDirectory"/>.</param>
        /// <param name="skipPdf">Initializes the required <see cref="SkipPdf"/>.</param>
        public ProjbookEngine(IFileSystem fileSystem, string csprojFile, string extensionPath, IndexConfiguration indexConfiguration, string outputDirectoryPath, bool skipPdf)
        {
            // Data validation
            Ensure.That(() => fileSystem).IsNotNull();
            Ensure.That(() => csprojFile).IsNotNullOrWhiteSpace();
            Ensure.That(() => indexConfiguration).IsNotNull();
            Ensure.That(() => indexConfiguration.Configurations).HasItems();
            Ensure.That(() => outputDirectoryPath).IsNotNullOrWhiteSpace();
            Ensure.That(fileSystem.File.Exists(csprojFile), string.Format("Could not find '{0}' file", csprojFile)).IsTrue();

            // Initialize
            this.fileSystem = fileSystem;
            this.CsprojFile = this.fileSystem.FileInfo.FromFileName(csprojFile);
            this.IndexConfiguration = indexConfiguration;
            this.OutputDirectory = this.fileSystem.DirectoryInfo.FromDirectoryName(outputDirectoryPath);
            this.snippetExtractorFactory = new SnippetExtractorFactory(this.fileSystem.DirectoryInfo.FromDirectoryName(this.fileSystem.Path.GetFullPath(extensionPath)));
            this.SkipPdf = skipPdf;
        }
 public override void Setup()
 {
     // Initialize extractor
     base.Setup();
     this.SnippetExtractorFactory = new SnippetExtractorFactory(this.CsprojFile);
 }
 public void Setup()
 {
     // Initialize extractor
     this.SnippetExtractorFactory = new SnippetExtractorFactory(TestsUtilities.EnsureExtensionsDeployed());
 }