Bloom.Book.XMatterHelper.XMatterHelper C# (CSharp) Method

XMatterHelper() public method

Constructs by finding the file and folder of the xmatter pack, given the its key name e.g. "Factory", "SILIndonesia". The name of the file should be (key)-XMatter.htm. The name and the location of the folder is not our problem... we leave it to the supplied fileLocator to find it.
public XMatterHelper ( HtmlDom bookDom, string nameOfXMatterPack, IFileLocator fileLocator ) : System
bookDom HtmlDom
nameOfXMatterPack string e.g. "Factory", "SILIndonesia"
fileLocator IFileLocator The locator needs to be able tell us the path to an xmater html file, given its name
return System
        public XMatterHelper(HtmlDom bookDom, string nameOfXMatterPack, IFileLocator fileLocator)
        {
            _bookDom = bookDom;
            _nameOfXMatterPack = nameOfXMatterPack;

            string directoryName = nameOfXMatterPack + "-XMatter";
            string directoryPath;
            try
            {
                directoryPath = fileLocator.LocateDirectoryWithThrow(directoryName);
            }
            catch(ApplicationException error)
            {
                var errorTemplate = LocalizationManager.GetString("Errors.XMatterNotFound",
                    "This Book called for Front/Back Matter pack named '{0}', but Bloom couldn't find that on this computer. You can either install a Bloom Pack that will give you '{0}', or go to Settings:Book Making and change to another Front/Back Matter Pack.");
                var msg = string.Format(errorTemplate, nameOfXMatterPack);

                ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), msg);
                //NB: we don't want to put up a dialog for each one; one failure here often means 20 more are coming as the other books are loaded!
                throw new ApplicationException(msg);
            }
            var htmName = nameOfXMatterPack + "-XMatter.html";
            PathToXMatterHtml = directoryPath.CombineForPath(htmName);
            if(!RobustFile.Exists(PathToXMatterHtml))
            {
                htmName = nameOfXMatterPack + "-XMatter.htm"; // pre- Bloom 3.7
                PathToXMatterHtml = directoryPath.CombineForPath(htmName);
            }
            if (!RobustFile.Exists(PathToXMatterHtml))
            {
                ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "Could not locate the file {0} in {1} (also checked .html)", htmName, directoryPath);
                throw new ApplicationException();
            }
            PathToStyleSheetForPaperAndOrientation = directoryPath.CombineForPath(GetStyleSheetFileName());
            if (!RobustFile.Exists(PathToXMatterHtml))
            {
                ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(), "Could not locate the file {0} in {1}", GetStyleSheetFileName(), directoryPath);
                throw new ApplicationException();
            }
            XMatterDom = XmlHtmlConverter.GetXmlDomFromHtmlFile(PathToXMatterHtml, false);
        }