User: xtoff
Date: 2009/12/15 12:09 AM
Modified:
/InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Facilities/FactorySupport/
FactorySupportTestCase.cs
/InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/EventWiring/
EventWiringFacility.cs
/InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/
BinaryTreeComponentName.cs, ComponentName.cs
/InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/
IoC-138.cs
Log:
- applied patch from Simon Cropp fixing IOC-ISSUE-172 Remove usages of
SpecializedCollections for silverlight
File Changes:
Directory: /InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/
===================================================================
File [modified]: IoC-138.cs
Delta lines: +0 -0
===================================================================
Directory:
/InversionOfControl/trunk/src/Castle.MicroKernel/Facilities/EventWiring/
===================================================================================
File [modified]: EventWiringFacility.cs
Delta lines: +12 -15
===================================================================
---
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/BinaryTreeComponentName.cs
2009-12-14 23:04:04 UTC (rev 6426)
+++
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/BinaryTreeComponentName.cs
2009-12-15 07:09:47 UTC (rev 6427)
@@ -15,7 +15,7 @@
namespace Castle.MicroKernel.SubSystems.Naming
{
using System;
- using System.Collections;
+ using System.Collections.Generic;
[Serializable]
public class BinaryTreeComponentName
@@ -36,9 +36,9 @@
{
get
{
- ArrayList list = new ArrayList();
+ var list = new List<IHandler>();
Visit(root, list);
- return
(IHandler[])list.ToArray(typeof(IHandler));
+ return list.ToArray();
}
}
@@ -115,7 +115,7 @@
if (node != null)
{
- ArrayList list = new ArrayList();
+ var list = new List<IHandler>();
list.Add(node.Handler);
@@ -126,13 +126,13 @@
list.Add(node.Handler);
}
- return
(IHandler[])list.ToArray(typeof(IHandler));
+ return list.ToArray();
}
return null;
}
- internal void Visit(TreeNode node, ArrayList list)
+ internal void Visit(TreeNode node, IList<IHandler> list)
{
if (node == null) return;
@@ -404,14 +404,11 @@
{
return this;
}
- else if (name.LiteralProperties == null ||
name.LiteralProperties == string.Empty)
+ if (string.IsNullOrEmpty(name.LiteralProperties))
{
return FindWithEmptyProperties();
}
- else
- {
- return FindBestMatchByProperties(name);
- }
+ return FindBestMatchByProperties(name);
}
private TreeNode FindWithEmptyProperties()
@@ -420,7 +417,7 @@
while (current != null)
{
- if (current.CompName.LiteralProperties == null
|| current.CompName.LiteralProperties == string.Empty)
+ if
(string.IsNullOrEmpty(current.CompName.LiteralProperties))
{
return current;
}
@@ -439,10 +436,10 @@
{
bool selected = true;
- foreach (DictionaryEntry entry in
name.Properties)
+ foreach (KeyValuePair<string, string> entry in
name.Properties)
{
- String value =
current.CompName.Properties[entry.Key] as String;
-
+ string value;
+
current.CompName.Properties.TryGetValue(entry.Key, out value);
if (value == null ||
!value.Equals(entry.Value))
{
Directory:
/InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Facilities/FactorySupport/
============================================================================================
File [modified]: FactorySupportTestCase.cs
Delta lines: +15 -10
===================================================================
--- InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/IoC-138.cs
2009-12-14 23:04:04 UTC (rev 6426)
+++ InversionOfControl/trunk/src/Castle.Windsor.Tests/Bugs/IoC-138.cs
2009-12-15 07:09:47 UTC (rev 6427)
@@ -12,14 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-using System.Collections;
-using System.Collections.Specialized;
-using Castle.MicroKernel;
-using NUnit.Framework;
-
namespace Castle.Windsor.Tests.Bugs
{
- [TestFixture]
+ using System.Collections.Generic;
+
+ using Castle.MicroKernel;
+
+ using NUnit.Framework;
+
+ [TestFixture]
public class IoC_138
{
[Test]
@@ -29,10 +30,14 @@
container.AddComponent("A", typeof(A));
container.AddComponent("B", typeof(B));
- IDictionary parameters = new ListDictionary();
- parameters.Add("test", "bla");
+ var parameters = new Dictionary<string,string>
+ {
+ {
+ "test", "bla"
+ }
+ };
- A a = container.Resolve<A>(parameters);
+ A a = container.Resolve<A>(parameters);
Assert.IsNotNull(a);
}
@@ -43,7 +48,7 @@
public A(IKernel kernel, string test)
{
- IDictionary parameters = new ListDictionary();
+ var parameters = new Dictionary<string,string>();
parameters.Add("test2", "bla");
b = kernel.Resolve<B>(parameters);
Directory: /InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/
==============================================================================
File [modified]: BinaryTreeComponentName.cs
Delta lines: +16 -37
===================================================================
---
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/ComponentName.cs
2009-12-14 23:04:04 UTC (rev 6426)
+++
InversionOfControl/trunk/src/Castle.MicroKernel/SubSystems/Naming/ComponentName.cs
2009-12-15 07:09:47 UTC (rev 6427)
@@ -15,9 +15,8 @@
namespace Castle.MicroKernel.SubSystems.Naming
{
using System;
+ using System.Collections.Generic;
using System.Text;
- using System.Collections;
- using System.Collections.Specialized;
using System.Runtime.Serialization;
[Serializable]
@@ -25,8 +24,8 @@
{
protected String internalService;
protected String internalliteralProperties = String.Empty;
- protected HybridDictionary internalproperties;
- protected bool allProperties;
+ protected IDictionary<string,string> internalproperties;
+ protected bool allProperties; // NOTE: is this safe to delete?
/// <summary>
/// Creates a ComponentName using a name pattern like
@@ -50,7 +49,7 @@
SetupProperties(properties);
}
- internal IDictionary Properties
+ internal IDictionary<string, string> Properties
{
get { return internalproperties; }
}
@@ -85,7 +84,7 @@
if (name.IndexOf(':') != -1)
{
- String[] splitted = name.Split(new char[]
{':'});
+ String[] splitted = name.Split(new[] {':'});
SetupService(splitted[0]);
SetupProperties(splitted[1]);
@@ -131,13 +130,13 @@
if (properties == String.Empty)
{
internalliteralProperties = "";
- SetupProperties(new HybridDictionary(true));
+ SetupProperties(new
Dictionary<string,string>(StringComparer.InvariantCultureIgnoreCase));
return;
}
- String[] props = properties.Split(new char[] {','});
+ String[] props = properties.Split(new[] {','});
- HybridDictionary propsHash = new HybridDictionary(true);
+ Dictionary<string, string> propsHash = new
Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase);
foreach (String chunk in props)
{
@@ -146,7 +145,7 @@
throw new ArgumentException("Invalid
properties.");
}
- String[] keyvalue = chunk.Split(new char[]
{'='});
+ String[] keyvalue = chunk.Split(new[] {'='});
String key = keyvalue[0];
String value = keyvalue[1];
@@ -161,44 +160,24 @@
/// Validates a properties Hashtable.
/// </summary>
/// <param name="properties">Property list.</param>
- protected virtual void SetupProperties(IDictionary properties)
+ protected virtual void SetupProperties(IDictionary<string,
string> properties)
{
- internalproperties = new HybridDictionary(true);
+ internalproperties = new
Dictionary<string,string>(StringComparer.InvariantCultureIgnoreCase);
StringBuilder sb = new StringBuilder();
- foreach (DictionaryEntry entry in properties)
+ foreach (KeyValuePair<string, string> entry in
properties)
{
if (sb.Length != 0)
{
sb.Append(",");
}
- String key = null;
+
- try
- {
- key = (String) entry.Key;
- }
- catch (InvalidCastException)
- {
- throw new ApplicationException("Key is
not a String.");
- }
+ sb.AppendFormat("{0}={1}", entry.Key,
entry.Value);
- String value = null;
-
- try
- {
- value = (String) entry.Value;
- }
- catch (InvalidCastException)
- {
- throw new ApplicationException("Value
is not a String.");
- }
-
- sb.AppendFormat("{0}={1}", key, value);
-
- Properties[key] = value;
+ Properties[entry.Key] = entry.Value;
}
internalliteralProperties = sb.ToString();
@@ -223,7 +202,7 @@
throw new ArgumentNullException("key");
}
- return (String) internalproperties[key];
+ return internalproperties[key];
}
}
File [modified]: ComponentName.cs
Delta lines: +8 -5
===================================================================
---
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Facilities/FactorySupport/FactorySupportTestCase.cs
2009-12-14 23:04:04 UTC (rev 6426)
+++
InversionOfControl/trunk/src/Castle.MicroKernel.Tests/Facilities/FactorySupport/FactorySupportTestCase.cs
2009-12-15 07:09:47 UTC (rev 6427)
@@ -15,19 +15,22 @@
namespace Castle.MicroKernel.Tests.Facilities.FactorySupport
{
using System;
- using System.Collections;
- using System.Collections.Specialized;
+ using System.Collections.Generic;
+
using Castle.Core;
using Castle.Core.Configuration;
using Castle.Facilities.FactorySupport;
using Castle.MicroKernel.Tests.ClassComponents;
+
using NUnit.Framework;
[TestFixture]
public class FactorySupportTestCase
{
IKernel kernel;
- [SetUp]public void SetUp()
+
+ [SetUp]
+ public void SetUp()
{
kernel = new DefaultKernel();
}
@@ -116,7 +119,7 @@
public class StringDictionaryDependentComponent
{
- public
StringDictionaryDependentComponent(StringDictionary d)
+ public
StringDictionaryDependentComponent(Dictionary<string, object> d)
{
}
}
@@ -130,7 +133,7 @@
public class HashTableDependentComponent
{
- public HashTableDependentComponent(Hashtable d)
+ public HashTableDependentComponent(Dictionary<object,
object> d)
{
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Commits" 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/castle-project-commits?hl=en.