Пример #1
0
        public void ParsePathTest()
        {
            //Get tokens and parse it
            TokenIterator tokens     = Init("site/home.html");
            SiteParser    siteParser = new SiteParser(tokens);
            Pth           path       = siteParser.ParsePath();

            //Get structures of path
            Dir         directory   = path.GetDirectoryName().GetDirectory();
            PathElement pathElement = (PathElement)directory.GetDirectoryElements().Get(0);
            FileName    filename    = path.GetFilename();


            //Check directory
            Assert.AreEqual(1, directory.GetDirectoryElements().Count);
            Assert.AreEqual("site", pathElement.GetPathElement());

            //Check filename
            Assert.AreEqual("home", filename.GetName().GetPathElement());
            Assert.AreEqual("html", filename.GetFileExtension().GetFileExtension());
        }
Пример #2
0
 public virtual void Visit(Path path)
 {
     VisitSubNodes(path);
 }
Пример #3
0
 /// <summary>
 /// Path to set
 /// </summary>
 /// <param name="path">Path of mapping</param>
 public void SetPath(Path path)
 {
     Path = path;
 }
Пример #4
0
        private Path Path; //Path of mapping

        #endregion Fields

        #region Constructors

        public Mapping()
        {
            //Create containers
            Path = new Path();
            Markup = new Markup.Markup();
        }
Пример #5
0
        /// <summary>
        /// Parse a path
        /// </summary>
        /// <returns>Parsed path</returns>
        public Path ParsePath()
        {
            Path path = new Path();

            //Determine if we have directories in path or just a filename
            if (TokenStream.Peek(2).GetValue().ToString() == ".")
            {   //Just a single filename to parse
                path.SetFilename(ParseFileName());
            }
            else
            {   //Directory and filename
                path.SetDirectoryName(ParseDirectoryName());
                path.SetFilename(ParseFileName());
            }

            return path;
        }