Author: fmantek
Date: Fri Apr 13 06:45:14 2007
New Revision: 131

Modified:
   trunk/clients/cs/src/core/utilities.cs
   trunk/clients/cs/src/unittests/coretest.cs

Log:
Fixed the TokenCollection code, that i broke for the mobile build

Modified: trunk/clients/cs/src/core/utilities.cs
==============================================================================
--- trunk/clients/cs/src/core/utilities.cs      (original)
+++ trunk/clients/cs/src/core/utilities.cs      Fri Apr 13 06:45:14 2007
@@ -420,7 +420,7 @@
             readStream.Close(); 
             Tracing.TraceMsg("got the following body back: " + body);
             // all we are interested is the token, so we break the string in 
parts
-            TokenCollection tokens = new TokenCollection(body, new char[1] 
{'='}, true, 2); 
+            TokenCollection tokens = new TokenCollection(body, '=', true, 2); 
             return tokens;
          }
         
/////////////////////////////////////////////////////////////////////////////
@@ -477,7 +477,7 @@
        }
 
          /// <summary>Constructor, takes a string and a delimiter 
set</summary> 
-       public TokenCollection(string source, char[] delimiters, 
+       public TokenCollection(string source, char delimiter, 
                               bool seperateLines, int resultsPerLine)
        {
            if (source != null)
@@ -493,20 +493,23 @@
                    {
                        // do not use Split(char,int) as that one
                        // does not exist on .NET CF
-                       string []temp = s.Split(delimiters);
-                      
-                       foreach (String r in temp)
+                       string []temp = s.Split(delimiter);
+                       int counter = temp.Length < resultsPerLine ? 
temp.Length : resultsPerLine;
+                    
+                       for (int i = 0; i <counter; i++) 
                        {
-                           this.elements[size++] = r;
-                           resultsPerLine--;
-                           if (resultsPerLine == 0)
-                               break;
+                           this.elements[size++] = temp[i];
                        }
+                       for (int i = resultsPerLine; i < temp.Length; i++) 
+                       {
+                           this.elements[size-1] += delimiter + temp[i];
+                       }
+             
                    }
                } 
                else 
                {
-                   string[] temp = source.Split(delimiters);
+                   string[] temp = source.Split(delimiter);
                    resultsPerLine = temp.Length < resultsPerLine ? temp.Length 
: resultsPerLine;
                    this.elements = new string[resultsPerLine];
 
@@ -514,6 +517,12 @@
                    {
                        this.elements[i] = temp[i];
                    }
+                   for (int i = resultsPerLine; i < temp.Length; i++) 
+                   {
+                       this.elements[resultsPerLine-1] += delimiter + temp[i];
+                   }
+             
+             
                } 
            }
        }

Modified: trunk/clients/cs/src/unittests/coretest.cs
==============================================================================
--- trunk/clients/cs/src/unittests/coretest.cs  (original)
+++ trunk/clients/cs/src/unittests/coretest.cs  Fri Apr 13 06:45:14 2007
@@ -455,7 +455,7 @@
             String toTest = 
"Test=Test?other=whatever\nTest2=Line2?other=whatishere";
 
             TokenCollection tokens = new TokenCollection(toTest, new char[] 
{'\n', '='});
-            TokenCollection tokenSmart = new TokenCollection(toTest, new 
char[] {'='}, true, 2);
+            TokenCollection tokenSmart = new TokenCollection(toTest, '=', 
true, 2);
 
             int iTokens = 0;
             foreach (string token in tokens)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data API" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to