当前位置: 首页>>代码示例>>C#>>正文


C# Address.GetAsContentPath方法代码示例

本文整理汇总了C#中Address.GetAsContentPath方法的典型用法代码示例。如果您正苦于以下问题:C# Address.GetAsContentPath方法的具体用法?C# Address.GetAsContentPath怎么用?C# Address.GetAsContentPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Address的用法示例。


在下文中一共展示了Address.GetAsContentPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplySubstitutions

        /// <summary>
        /// Apply macro substitutions to a string based on things in the ViewContext
        /// </summary>
        /// <param name="s">The string with macros</param>
        /// <param name="viewContext">The ViewContext in which the string will be displayed</param>
        /// <returns>The string with macros substituted</returns>
        public string ApplySubstitutions(string s, ViewContext viewContext)
        {
            dynamic viewBag = viewContext.ViewBag;
            string subs = (s ?? "")
             .Replace("$$CurrentUrl$$", viewContext.HttpContext.Request.Url.OriginalString)
             .Replace("$$BaseUrl$$", viewBag._Lyn_BaseUrl)
             .Replace("$$OriginalQuery$$", viewBag.OriginalQuery);

            if (viewContext.ViewData.Model != null)
            {
                var address = new Address(viewContext.ViewData.Model.GetType().ContentType(), viewContext.RouteData);
                subs = subs
                    .Replace("$$Path$$", address.GetAsContentPath())
                    .Replace("$$Type$$", address.Type.FullName);
            }

            return subs;
        }
开发者ID:jamesej,项目名称:lynicon,代码行数:24,代码来源:UIElement.cs

示例2: AddressObjectConstructor

        public void AddressObjectConstructor()
        {
            var a1 = new Address(paDatas2[0]);
            Assert.AreEqual("a", a1["_0"]);
            Assert.AreEqual(1, a1["_1"]);
            Assert.AreEqual("a&001", a1.GetAsContentPath());
            Assert.AreEqual("001", a1.GetAsString("_1"));

            var a2 = new Address(paDatas[2]);
            Assert.AreEqual("a", a2["_0"]);
            Assert.AreEqual("b", a2["_1"]);
            Assert.AreEqual("a&b", a2.GetAsContentPath());
        }
开发者ID:jamesej,项目名称:lynicon,代码行数:13,代码来源:AddressTests.cs

示例3: AddressRouteDataConstructor

        public void AddressRouteDataConstructor()
        {
            var rd = new RouteData();
            var a1 = new Address(typeof(HeaderContent), rd);
            Assert.AreEqual("", a1.GetAsContentPath());

            rd.Values.Add("_0", "qqq");
            var a2 = new Address(typeof(HeaderContent), rd);
            Assert.AreEqual("qqq", a2.GetAsContentPath());

            rd.Values.Add("_1", "abc");
            var a3 = new Address(typeof(HeaderContent), rd);
            Assert.AreEqual("qqq&abc", a3.GetAsContentPath());
            Assert.AreNotEqual(a2.GetAsContentPath(), a3.GetAsContentPath(), "Address immutable via changing constructor arg");
        }
开发者ID:jamesej,项目名称:lynicon,代码行数:15,代码来源:AddressTests.cs


注:本文中的Address.GetAsContentPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。