本文整理汇总了C#中PathString.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PathString.Add方法的具体用法?C# PathString.Add怎么用?C# PathString.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathString
的用法示例。
在下文中一共展示了PathString.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateClientUrl
private static string GenerateClientUrl(PathString applicationPath, string path)
{
if (path.StartsWith("~/", StringComparison.Ordinal))
{
var segment = new PathString(path.Substring(1));
return applicationPath.Add(segment).Value;
}
return path;
}
示例2: AddPathString_HandlesLeadingAndTrailingSlashes
public void AddPathString_HandlesLeadingAndTrailingSlashes(string appString, string concatString, string expected)
{
// Arrange
var appPath = new PathString(appString);
var concatPath = new PathString(concatString);
// Act
var result = appPath.Add(concatPath);
// Assert
Assert.Equal(expected, result.Value);
}
示例3: AddPathString_HandlesNullAndEmptyStrings
public void AddPathString_HandlesNullAndEmptyStrings(string appString, string concatString)
{
// Arrange
var appPath = new PathString(appString);
var concatPath = new PathString(concatString);
// Act
var result = appPath.Add(concatPath);
// Assert
Assert.False(result.HasValue);
}
示例4: PathAndQueryStringAreCombinable
public void PathAndQueryStringAreCombinable(
string pathValue,
string queryValue,
string combinedValue)
{
var path = new PathString(pathValue);
var query = new QueryString(queryValue);
path.Add(query).ShouldBe(combinedValue);
(path + query).ShouldBe(combinedValue);
}
示例5: Resolve
public PathString Resolve(VirtualPathContext virtualPathContext, RequestCulture defaultRequestCulture, RequestCulture requestCulture)
{
// Handle when the page is added as a route parameter
object value;
if (virtualPathContext.Values.TryGetValue("page", out value))
{
var page = value as Page;
if (page == null) return null;
object culture;
if (virtualPathContext.Values.TryGetValue("culture", out culture))
{
string cultureValue = culture as string;
if (cultureValue != null)
{
requestCulture = new RequestCulture(cultureValue);
}
}
var trie = _routeResolverTrie.LoadTrieAsync(requestCulture);
trie.Wait();
var node = trie.Result.FirstOrDefault(n => n.Value.PageId == page.Id);
PathString path = new PathString();
if (defaultRequestCulture.Culture.Name != requestCulture.Culture.Name)
{
path = path.Add("/" + requestCulture.Culture.TwoLetterISOLanguageName);
}
return path.Add(node.Key);
}
if (virtualPathContext.Values.TryGetValue("id", out value))
{
var id = value as string;
if (id == null) return null;
object culture;
if (virtualPathContext.Values.TryGetValue("culture", out culture))
{
string cultureValue = culture as string;
if (cultureValue != null)
{
requestCulture = new RequestCulture(cultureValue);
}
}
var trie = _routeResolverTrie.LoadTrieAsync(requestCulture);
trie.Wait();
var node = trie.Result.FirstOrDefault(n => n.Value.PageId == id);
PathString path = new PathString();
if (defaultRequestCulture.Culture.Name != requestCulture.Culture.Name)
{
path = path.Add("/" + requestCulture.Culture.TwoLetterISOLanguageName);
}
return path.Add(node.Key);
}
return null;
}