本文整理汇总了C#中System.Resolver.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Resolver.RemoveAt方法的具体用法?C# Resolver.RemoveAt怎么用?C# Resolver.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Resolver
的用法示例。
在下文中一共展示了Resolver.RemoveAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCache
public void TestCache() {
Resolver<ContentType> resolver = new Resolver<ContentType>();
resolver.Add(new ContentType("*.html", "text/html"));
resolver.Add(new ContentType("*.jpg", "image/jpeg"));
resolver.Add(new ContentType("/images/*", "image/jpeg"));
resolver.Add(new ContentType("/log/**", "text/plain"));
resolver.Add(new ContentType("*.exe", "application/octetstream"));
resolver.Add(new ContentType("**.txt", "text/plain"));
resolver.Add(new ContentType("/html/*", "text/html"));
AssertEquals(7, resolver.Count);
AssertEquals("image/jpeg", resolver.Resolve("image.jpg").Value);
AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
int index = 0;
for(int i = resolver.Count; i > 0; i--) {
ContentType type = resolver[i - 1];
if(type.Value.Equals("text/plain")) {
index = i;
}
}
resolver.RemoveAt(index);
resolver.Add(new ContentType("*", "application/octetstream"));
AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
AssertEquals("application/octetstream", resolver.Resolve("README.txt").Value);
resolver.Add(new ContentType("README.*", "text/html"));
resolver.Add(new ContentType("README.txt", "text/plain"));
AssertEquals("text/plain", resolver.Resolve("README.txt").Value);
AssertEquals("text/html", resolver.Resolve("README.jsp").Value);
}