Пример #1
0
 private void SaveDirectory(Document directory, string path, bool content)
 {
     if (!System.NodeExists(path))
     {
         System.CreateNode(path);
     }
     if (NeedsDirectoryDocument(directory))
     {
         WriteDocument(directory, Path.Combine(path, DirectoryDocumentName), content);
     }
     if (directory.IsLeaf)
     {
         return;
     }
     foreach (var child in directory.Children)
     {
         if (!child.IsLeaf)
         {
             SaveDirectory(child, GetDocumentPath(directory, child, path), content);
         }
         else
         {
             SaveFile(directory, child, path, content);
         }
     }
 }
        /// <summary>
        /// Extracts the inline styles, optimizes CSS and adds CSS classes in the head section for current page
        /// </summary>
        /// <param name="xmlDoc">A reference to a XmlDocument instance.</param>
        public void Filter(ref System.Xml.XmlDocument xmlDoc)
        {
            XmlNode body = xmlDoc.GetElementsByTagName("body")[0];
            XmlNode head = xmlDoc.GetElementsByTagName("head")[0];
            if (head == null)
            {
                head = xmlDoc.CreateNode(XmlNodeType.Element, "head", xmlDoc.NamespaceURI);
                body.ParentNode.InsertBefore(head, body);
            }

            //step1: inline CSS for existing CSS classes and ids, for better manipulation at step2 and step3
            CSSUtil.InlineCSS(ref xmlDoc);

            //step2: convert all inlined style to CSS classes
            //(including, but not limited to, those generated at step1)
            body = CSSUtil.ConvertInlineStylesToCssClasses(body, ref xmlDoc, ref counter, ref cssClasses);

            //step3: optimize CSS by grouping selectors with the same properties
            cssClasses = CSSUtil.GroupCSSSelectors(cssClasses);

            InsertCssClassesInHeader(ref head, ref xmlDoc);
        }
Пример #3
0
        public void Save(Document project, bool commit = true, string message = null)
        {
            var repositoryService = GetRepositoryService(project);
            var path = Path.Combine(Root, project.User.Path, project.Name);

            if (project.Disconnect)
            {
                if (!System.NodeExists(path))
                {
                    System.CreateNode(path);
                }
            }
            else
            {
                if (!repositoryService.IsRepo(path))
                {
                    gitHubService.Create(project);
                }
                if (System.NodeExists(path))
                {
                    repositoryService.Pull(path);
                }
                else
                {
                    repositoryService.Clone(gitHubService.GetRepoName(project), path);
                }
            }
            EmptyProject(path);
            SaveDirectory(project, Path.Combine(Root, project.Path), true);
            if (message == null)
            {
                message = DateTime.Now.ToString();
            }
            if (!project.Disconnect && commit)
            {
                repositoryService.Commit(path, message);
            }
        }
Пример #4
0
        public Document LoadDirectory(User user, Document parent, string path, bool content)
        {
            if (!System.NodeExists(path))
            {
                System.CreateNode(path);
            }
            var directory         = GetDocument(user, parent, path, false, parent?.IndexNodes ?? false);
            var directoryDocument = System.GetLeaves(path, DirectoryDocumentName).SingleOrDefault();

            if (directoryDocument != null)
            {
                ReadMetadata(directory, directoryDocument);
                if (content)
                {
                    ReadDocument(directory, directoryDocument);
                }
            }
            else
            {
                SetMetadata(directory);
            }
            directory.Children = GetChildren(directory, user, path, content);
            return(directory);
        }
 public void CreateDiscriminator(object info, System.Xml.XmlDocument xmlDocument)
 {
     var node = xmlDocument.CreateNode(XmlNodeType.Element, Constants.DISCRIMINATOR, "");
     node.InnerText = ReflectionUtils.GetTypeFullName_With_AssemblyName_WihoutVersion(info.GetType());
     xmlDocument.DocumentElement.AppendChild(node);
 }
        /// <summary>
        /// Stores the numeric option as an XML Node (calls base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the information of numeric option</returns>
        internal XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Min_Value
            XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", "");
            minNode.InnerText = this.min_value.ToString();
            node.AppendChild(minNode);

            //Max_Value
            XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", "");
            maxNode.InnerText = this.max_value.ToString();
            node.AppendChild(maxNode);

            if (this.stepFunction != null)
            {
                //StepFunction
                XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", "");
                stepNode.InnerText = this.stepFunction.ToString();
                node.AppendChild(stepNode);
            }

            if (values != null)
            {
                //Values
                XmlNode valuesNode = doc.CreateNode(XmlNodeType.Element, "values", "");
                String valuesAsString = "";
                for (int i = 0; i < values.Count(); i++)
                {
                    valuesAsString += values[i] + ";";
                }
                // remove last ;
                valuesAsString = valuesAsString.Substring(0, valuesAsString.Count() - 2);

                valuesNode.InnerText = valuesAsString;
                node.AppendChild(valuesNode);
            }

            //DefaultValue
            XmlNode defNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", "");
            defNode.InnerText = this.defaultValue.ToString();
            node.AppendChild(defNode);

            return node;
        }
        /// <summary>
        /// Stores the numeric option as an XML Node (calls base implementation)
        /// </summary>
        /// <param name="doc">The XML document to which the node will be added</param>
        /// <returns>The XML node containing the information of numeric option</returns>
        internal XmlNode saveXML(System.Xml.XmlDocument doc)
        {
            XmlNode node = base.saveXML(doc);

            //Min_Value
            XmlNode minNode = doc.CreateNode(XmlNodeType.Element, "minValue", "");
            minNode.InnerText = this.min_value.ToString();
            node.AppendChild(minNode);

            //Max_Value
            XmlNode maxNode = doc.CreateNode(XmlNodeType.Element, "maxValue", "");
            maxNode.InnerText = this.max_value.ToString();
            node.AppendChild(maxNode);

            //StepFunction
            XmlNode stepNode = doc.CreateNode(XmlNodeType.Element, "stepFunction", "");
            stepNode.InnerText = this.stepFunction.ToString();
            node.AppendChild(stepNode);

            //DefaultValue
            XmlNode defNode = doc.CreateNode(XmlNodeType.Element, "defaultValue", "");
            defNode.InnerText = this.defaultValue.ToString();
            node.AppendChild(defNode);

            return node;
        }