Exemplo n.º 1
0
 public void T2()
 {
   var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true");
   var pat = new URIPattern("{year}/{month}/{title}");
   
   var match = pat.MatchURIPath(uri);   
   Assert.IsNull(match);
 }
Exemplo n.º 2
0
        public void MakeURI_T2_params()
        {
            var pattern = new URIPattern("{year}/values?{p1}={v1}&par2={v2}");
            var map = new JSONDataMap { { "year", "1980" }, { "p1", "par1" }, { "v1", 10 }, { "v2", "val2" } };

            var uri = pattern.MakeURI(map);

            Assert.AreEqual(new Uri("1980/values?par1%3D10%26par2%3Dval2", UriKind.RelativeOrAbsolute), uri);
        }
Exemplo n.º 3
0
        public void MakeURI_T1_noprefix()
        {
            var pattern = new URIPattern("/news/{year}/{month}/{title}");
            var map = new JSONDataMap { { "year", "1981" }, { "month", 12 }, { "title", "some_title" } };

            var uri = pattern.MakeURI(map);

            Assert.AreEqual(new Uri("/news/1981/12/some_title", UriKind.RelativeOrAbsolute), uri);
        }
Exemplo n.º 4
0
        public void MakeURI_T1_prefix()
        {
            var pattern = new URIPattern("{year}/{month}/{title}");
            var prefix = new Uri("http://test.com");
            var map = new JSONDataMap { { "year", "1981" }, { "month", 12 }, { "title", "some_title" } };

            var uri = pattern.MakeURI(map, prefix);

            Assert.AreEqual(new Uri(prefix, "http://test.com/1981/12/some_title"), uri);
        }
Exemplo n.º 5
0
 public void T4_defaults()
 {
   var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true");
   var pat = new URIPattern("news/{year}/{month}/{title=overview}");
   
   var match = pat.MatchURIPath(uri);   
   Assert.IsNotNull(match);
   Assert.AreEqual("2012", match["year"]);
   Assert.AreEqual("sep", match["month"]);
   Assert.AreEqual("mayor-gets-elected", match["title"]);
 }
Exemplo n.º 6
0
        public WorkMatch(IConfigSectionNode confNode)
        {
            if (confNode == null)
            {
                throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName + ".ctor(node==null)");
            }

            m_Name  = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);

            if (m_Name.IsNullOrWhiteSpace())
            {
                m_Name = "{0}({1})".Args(GetType().FullName, Guid.NewGuid());
            }

            var ppattern = confNode.AttrByName(CONFIG_PATH_ATTR).Value;

            if (ppattern.IsNotNullOrWhiteSpace())
            {
                m_PathPattern = new URIPattern(ppattern);
            }

            var nppattern = confNode.AttrByName(CONFIG_NOT_PATH_ATTR).Value;

            if (nppattern.IsNotNullOrWhiteSpace())
            {
                m_NotPathPattern = new URIPattern(nppattern);
            }

            //Variables
            foreach (var vnode in confNode.Children.Where(c => c.IsSameName(CONFIG_VAR_SECTION)))
            {
                m_Variables.Register(new Variable(vnode));
            }

            ConfigAttribute.Apply(this, confNode);

            var permsNode = confNode[Permission.CONFIG_PERMISSIONS_SECTION];

            if (permsNode.Exists)
            {
                m_Permissions = Permission.MultipleFromConf(permsNode);
            }
        }
Exemplo n.º 7
0
        public void T10()
        {
            var uri = new Uri("http://russia.ru/news/2012/sep/mayor%2egets%2eelected/");
              var pat = new URIPattern("news/{year}/{month}/{title}");

              var match = pat.MatchURIPath(uri);
              Assert.IsNotNull(match);
              Assert.AreEqual("2012", match["year"]);
              Assert.AreEqual("sep", match["month"]);
              Assert.AreEqual("mayor.gets.elected", match["title"]);
        }
Exemplo n.º 8
0
 public void T9()
 {
     var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected/presidential?bonus=true");
       var pat = new URIPattern("news/{*path}/cantbe");
 }
Exemplo n.º 9
0
        public void T8()
        {
            var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected/presidential?bonus=true");
              var pat = new URIPattern("news/{*path}");

              var match = pat.MatchURIPath(uri);
              Assert.IsNotNull(match);
              Assert.AreEqual("2012/sep/mayor-gets-elected/presidential", match["path"]);
        }
Exemplo n.º 10
0
        public void T11_case_sensitive()
        {
            var uri = new Uri("http://russia.ru/news/2012/sep/mayor%2egets%2eelected/");
              var pat = new URIPattern("NEWS/{year}/{month}/{title}");

              var match = pat.MatchURIPath(uri, senseCase: true);
              Assert.IsNull(match);
        }
Exemplo n.º 11
0
        private void button3_Click(object sender, EventArgs e)
        {
            var pat = new URIPattern(tbPattern.Text);

              var uri = new Uri("http://localhost:8080/cities/cleveland.htm?port=true&law=%2e%2d%56");

            //  MessageBox.Show(pat._____Chunks);

              var nu = pat.MakeURI(new Dictionary<string, object>
                  {
                     {"city", "Hamburg"},
                     {"state", "Ohio"}
                  }, new Uri("http://test.com"));

              MessageBox.Show(nu.ToString());

             // Text = pat.MatchURI( uri )["city"].ToString();
        }
Exemplo n.º 12
0
        public WorkMatch(IConfigSectionNode confNode)
        {
            if (confNode==null)
              throw new WaveException(StringConsts.ARGUMENT_ERROR + GetType().FullName+".ctor(node==null)");

            m_Name = confNode.AttrByName(Configuration.CONFIG_NAME_ATTR).Value;
            m_Order = confNode.AttrByName(Configuration.CONFIG_ORDER_ATTR).ValueAsInt(0);

            if (m_Name.IsNullOrWhiteSpace())
              m_Name = "{0}({1})".Args(GetType().FullName, Guid.NewGuid());

            var ppattern = confNode.AttrByName(CONFIG_PATH_ATTR).Value;
            if (ppattern.IsNotNullOrWhiteSpace())
              m_PathPattern = new URIPattern( ppattern );

            var nppattern = confNode.AttrByName(CONFIG_NOT_PATH_ATTR).Value;
            if (nppattern.IsNotNullOrWhiteSpace())
              m_NotPathPattern = new URIPattern( nppattern );

            //Variables
            foreach(var vnode in confNode.Children.Where(c=>c.IsSameName(CONFIG_VAR_SECTION)))
              m_Variables.Register(new Variable(vnode) );

            ConfigAttribute.Apply(this, confNode);

            var permsNode = confNode[Permission.CONFIG_PERMISSIONS_SECTION];
            if (permsNode.Exists)
              m_Permissions = Permission.MultipleFromConf(permsNode);
        }