예제 #1
0
        private static IEnumerable <GeckoElement> FindMatchingSpans(ConfigurableDictionaryNode selectedNode, GeckoElement parent,
                                                                    ConfigurableDictionaryNode topLevelNode, FdoCache cache)
        {
            var elements     = new List <GeckoElement>();
            var desiredClass = CssGenerator.GetClassAttributeForConfig(selectedNode);

            if (ConfiguredXHTMLGenerator.IsCollectionNode(selectedNode, cache))
            {
                desiredClass = CssGenerator.GetClassAttributeForCollectionItem(selectedNode);
            }
            foreach (var span in parent.GetElementsByTagName("span"))
            {
                if (span.GetAttribute("class") != null && span.GetAttribute("class").Split(' ')[0] == desiredClass &&
                    DoesGeckoElementOriginateFromConfigNode(selectedNode, span, topLevelNode))
                {
                    elements.Add(span);
                }
            }
            return(elements);
        }
예제 #2
0
        private static List <GeckoElement> FindConfiguredItem(ConfigurableDictionaryNode selectedConfigNode, GeckoWebBrowser browser, FdoCache cache)
        {
            var elements = new List <GeckoElement>();
            var body     = browser.Document.Body;

            if (body == null || selectedConfigNode == null)             // Sanity check
            {
                return(elements);
            }

            var topLevelConfigNode = GetTopLevelNode(selectedConfigNode);
            var topLevelClass      = CssGenerator.GetClassAttributeForConfig(topLevelConfigNode);

            foreach (var div in body.GetElementsByTagName("div"))
            {
                if (Equals(div.ParentElement, body) && div.GetAttribute("class") == topLevelClass)
                {
                    elements.AddRange(FindMatchingSpans(selectedConfigNode, div, topLevelConfigNode, cache));
                }
            }
            return(elements);
        }
예제 #3
0
        private bool CreateDocumentation()
        {
            const bool lRet       = false;
            var        htmlFolder = HtmlFormatters.URLReplace(Xml.HtmlFolder + Xml.ProjectTitle);
            var        htmlfile   = "";
            var        dir        = new DirectoryInfo(htmlFolder);

            try
            {
                if (Xml.DeleteFiles == "true" && Directory.Exists(htmlFolder))
                {
                    dir.Delete(true);
                }
            }
            catch (IOException e)
            {
                Logging.WriteLog("ATTENTION: IT WAS NOT POSSIBLE TO EXCLUDE THE DIRECTORY: " + dir.FullName + ". THE PROCESS WILL CONTINUE.\n" + e);
            }
            Directory.CreateDirectory(htmlFolder);

            #region Copiando arquivos css originais do bináiro para o diretório HTML:
            var css = new CssGenerator();
            css.LoadXml(Xml);
            css.CopyCss(htmlFolder);
            #endregion

            #region CRIANDO ÁRVORE DE PASTAS E ROTINAS PARA A NAVEGAÇÃO PRINCIPAL
            Create_Tree(Xml.LocalFolder);
            // Ajuste final na árvore:
            Tree = Tree.Replace(@"},]", @"}]").Replace(@"],}", @"]}");
            Tree = Tree.Substring(0, Tree.Length - 2);
            #endregion

            #region CRIANDO ARQUIVO NAVIGATION PRINCIPAL (MAIN.HTML)
            //Iniciando o project com o arquivo Main.Html
            htmlfile = htmlFolder + @"\main.html";
            CreateHTMLFile(htmlfile, "Navigation.html");
            Replace_TreeArea(htmlfile);
            Replace_NameArea(htmlfile, Xml.ProjectTitle);
            Replace_ButtonArea(Xml.LocalFolder, htmlfile);
            Replace_FileProtocolArea(htmlfile);
            Replace_SearchArea(htmlfile, true);
            Replace_BreadcrumbArea(htmlfile, htmlfile);
            Replace_Dictionary(htmlfile);

            Logging.WriteLog("main.html file created successfully. Generating the documentation.");
            #endregion

            #region CRIANDO ARQUIVOS CODE
            var tfsFolder = new DirectoryInfo(Xml.LocalFolder);
            var counter   = tfsFolder.EnumerateFiles("*", SearchOption.AllDirectories).Count(d => Xml.Extensions.Contains(d.Extension.ToLower()));
            var current   = 0;

            foreach (var codefile in tfsFolder.EnumerateFiles("*", SearchOption.AllDirectories)
                     .Where(d => Xml.Extensions.Contains(d.Extension.ToLower())))
            {
                current++;
                Logging.WriteLog(current + " of " + counter + " files processed.", true);
                var originalfilename = codefile.FullName;
                //var newdirectory = WebUtility.HtmlEncode(codefile.Directory.FullName);
                var newdirectory = HtmlFormatters.URLReplace(codefile.Directory.FullName);
                newdirectory = (newdirectory.Substring(newdirectory.Length - 1) == @"\") ? newdirectory : newdirectory + @"\";
                newdirectory = htmlFolder + @"\" + HtmlFormatters.URLReplace(newdirectory.Replace(Xml.LocalFolder, ""));
                Directory.CreateDirectory(newdirectory);

                htmlfile = HtmlFormatters.URLReplace(codefile.Name) + ".html";
                htmlfile = newdirectory + @"\" + htmlfile;
                byte[] result;

                System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
                // This is one implementation of the abstract class SHA1.
                FileStream fs = File.OpenRead(originalfilename);
                result = sha.ComputeHash(fs);
                var SHA1 = "";
                foreach (var line in result)
                {
                    SHA1 += line.ToString();
                }
                fs.Close();
                if (!File.Exists(htmlfile) || FileHash.CompareHash(htmlfile, SHA1))
                {
                    CreateHTMLFile(htmlfile, "Code.html", SHA1);
                    Replace_NameArea(htmlfile, Xml.ProjectTitle);
                    Replace_FileNameArea(htmlfile, codefile.Name);
                    Replace_FileProtocolArea(htmlfile);
                    FileInfo f = new FileInfo(htmlfile);
                    Replace_SearchArea(htmlfile, f.Directory.FullName.ToLower() != searchFolder, f.Directory.FullName);
                    Replace_BreadcrumbArea(htmlfile, originalfilename);
                    RegExDocumentation(htmlfile, codefile.FullName);
                    RegExCode(htmlfile, codefile.FullName);
                    Replace_History(htmlfile, codefile.FullName);
                    Replace_Dictionary(htmlfile);
                }
            }
            #endregion

            return(lRet);
        }