diff options
Diffstat (limited to 'src/DotNetOpenId/Util.cs')
-rw-r--r-- | src/DotNetOpenId/Util.cs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/DotNetOpenId/Util.cs b/src/DotNetOpenId/Util.cs index af00898..5671c6d 100644 --- a/src/DotNetOpenId/Util.cs +++ b/src/DotNetOpenId/Util.cs @@ -338,7 +338,7 @@ namespace DotNetOpenId { // The characters to escape here are inspired by
// http://code.google.com/p/doctype/wiki/ArticleXSSInJavaScript
- static readonly Dictionary<string, string> javascriptStaticStringEscaping = new Dictionary<string,string> {
+ static readonly Dictionary<string, string> javascriptStaticStringEscaping = new Dictionary<string, string> {
{"\\", @"\\" }, // this WAS just above the & substitution but we moved it here to prevent double-escaping
{"\t", @"\t" },
{"\n", @"\n" },
@@ -403,6 +403,29 @@ namespace DotNetOpenId { }
}
}
+ internal static bool Contains<T>(IEnumerable<T> sequence, Func<T, bool> predicate) {
+ foreach (T item in sequence) {
+ if (predicate(item)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ internal static IEnumerable<T> Cast<T>(System.Collections.IEnumerable sequence) {
+ foreach (object item in sequence) {
+ yield return (T)item;
+ }
+ }
+ internal static int Count(System.Collections.IEnumerable sequence) {
+ int count = 0;
+ foreach (object item in sequence) {
+ count++;
+ }
+
+ return count;
+ }
+
/// <summary>
/// Tests two sequences for same contents and ordering.
/// </summary>
@@ -413,7 +436,7 @@ namespace DotNetOpenId { IEnumerator<T> iterator1 = sequence1.GetEnumerator();
IEnumerator<T> iterator2 = sequence2.GetEnumerator();
- bool movenext1 , movenext2;
+ bool movenext1, movenext2;
while (true) {
movenext1 = iterator1.MoveNext();
movenext2 = iterator2.MoveNext();
@@ -457,7 +480,7 @@ namespace DotNetOpenId { foreach (T obj in l) {
// Prepare the string repersentation of the object
string objString = obj != null ? obj.ToString() : "<NULL>";
-
+
// Indent every line printed
objString = objString.Replace(Environment.NewLine, Environment.NewLine + "\t");
sb.Append("\t");
|