diff options
Diffstat (limited to 'cs/src/Ice/AssemblyUtil.cs')
-rw-r--r-- | cs/src/Ice/AssemblyUtil.cs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/cs/src/Ice/AssemblyUtil.cs b/cs/src/Ice/AssemblyUtil.cs index f6e3fd39be6..e0ba2b094ac 100644 --- a/cs/src/Ice/AssemblyUtil.cs +++ b/cs/src/Ice/AssemblyUtil.cs @@ -56,8 +56,7 @@ namespace IceInternal xp_ = v.Major == 5 && v.Minor == 1; // Are we running on XP? osx_ = false; - -#if COMPACT +#if COMPACT || SILVERLIGHT // // Populate the _iceAssemblies list with the fully-qualified names // of the standard Ice assemblies. The fully-qualified name looks @@ -82,7 +81,7 @@ namespace IceInternal _iceAssemblies.Add("IceStorm," + suffix); } #else - if(platform_ == Platform.NonWindows) + if (platform_ == Platform.NonWindows) { try { @@ -113,18 +112,18 @@ namespace IceInternal public static Type findType(Instance instance, string csharpId) { -#if !COMPACT +#if !COMPACT && !SILVERLIGHT loadAssemblies(); // Lazy initialization #endif lock(_mutex) { - Type t = (Type)_typeTable[csharpId]; - if(t != null) + Type t; + if (_typeTable.TryGetValue(csharpId, out t)) { return t; } -#if COMPACT +#if COMPACT || SILVERLIGHT string[] assemblies = instance.factoryAssemblies(); for(int i = 0; i < assemblies.Length; ++i) { @@ -151,7 +150,7 @@ namespace IceInternal } } #else - foreach(Assembly a in _loadedAssemblies.Values) + foreach (Assembly a in _loadedAssemblies.Values) { if((t = a.GetType(csharpId)) != null) { @@ -164,10 +163,10 @@ namespace IceInternal return null; } -#if !COMPACT +#if !COMPACT && !SILVERLIGHT public static Type[] findTypesWithPrefix(string prefix) { - IceUtilInternal.LinkedList l = new IceUtilInternal.LinkedList(); + LinkedList<Type> l = new LinkedList<Type>(); loadAssemblies(); // Lazy initialization @@ -180,7 +179,7 @@ namespace IceInternal { if(t.AssemblyQualifiedName.IndexOf(prefix, StringComparison.Ordinal) == 0) { - l.Add(t); + l.AddLast(t); } } } @@ -207,7 +206,7 @@ namespace IceInternal } } -#if !COMPACT +#if !COMPACT && !SILVERLIGHT // // Make sure that all assemblies that are referenced by this process // are actually loaded. This is necessary so we can use reflection @@ -242,7 +241,7 @@ namespace IceInternal AssemblyName[] names = a.GetReferencedAssemblies(); foreach(AssemblyName name in names) { - if(!_loadedAssemblies.Contains(name.FullName)) + if(!_loadedAssemblies.ContainsKey(name.FullName)) { try { @@ -263,8 +262,8 @@ namespace IceInternal #else private static List<string> _iceAssemblies = new List<string>(); #endif - private static Hashtable _typeTable = new Hashtable(); // <type name, Type> pairs. - private static Mutex _mutex = new Mutex(); + private static Dictionary<string, Type> _typeTable = new Dictionary<string, Type>(); // <type name, Type> pairs. + private static Object _mutex = new Object(); public readonly static Runtime runtime_; // Either DotNET or Mono // |