Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Components / Binder / Castle.Components.Binder.Tests / TestUtils.cs
blobccf97f9cfd97c25496968ddfeb5042e6e4b53ca6
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Components.Binder.Tests
17 using System;
18 using System.Collections.Specialized;
20 public class TestUtils
22 /// <summary>
23 /// Parse a string in this format:
24 /// @"
25 /// Person@count = 2
26 /// Person[0].Name = Gi Joe
27 /// Person[0].Age = 32
28 /// Person[1].Name = Mary
29 /// Person[1].Age = 16
30 /// ";
31 /// and return a NameValueCollection with these elements
32 ///
33 /// "Person@count" => "2"
34 /// "Person[0].Name" => "Gi Joe"
35 /// "Person[0].Age" => "32"
36 /// "Person[1].Name" => "Mary"
37 /// "Person[1].Age" => "16"
38 /// </summary>
39 /// <param name="data"></param>
40 /// <returns></returns>
41 /// <remarks>
42 /// Notice that any that leading and trailing spaces are discarded
43 /// </remarks>
44 public static NameValueCollection ParseNameValueString(String data)
46 NameValueCollection args = new NameValueCollection();
48 data = data.Trim();
50 foreach(string nameValue in data.Split('\n'))
52 if (nameValue.Trim() == "") continue;
54 string[] pair = nameValue.Split('=');
55 args.Add(pair[0].Trim(), pair[1].Trim());
58 return args;