本文整理汇总了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;
}
示例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());
}
示例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");
}