# HG changeset patch # User srobbins <> # Date 1270492920 -3600 # Node ID df88f6f65a44f2861660408e226beaa62a4446c1 # Parent d55f4c95f2e3a014de9f1d4594352914c22629b8 Added support for Silverlight for AutoRegister diff -r d55f4c95f2e3a014de9f1d4594352914c22629b8 -r df88f6f65a44f2861660408e226beaa62a4446c1 TinyIoC/TinyIoC.cs --- a/TinyIoC/TinyIoC.cs Mon Apr 05 17:50:44 2010 +0100 +++ b/TinyIoC/TinyIoC.cs Mon Apr 05 19:42:00 2010 +0100 @@ -33,6 +33,10 @@ #undef APPDOMAIN_GETASSEMBLIES #undef UNBOUND_GENERICS_GETCONSTRUCTORS #endif + +#if SILVERLIGHT + #undef APPDOMAIN_GETASSEMBLIES +#endif #endregion using System; @@ -1586,7 +1590,7 @@ if (this.Type != typeRegistration.Type) return false; - if (String.Compare(this.Name, typeRegistration.Name, true) != 0) + if (String.Compare(this.Name, typeRegistration.Name, StringComparison.Ordinal) != 0) return false; return true; @@ -1633,7 +1637,14 @@ { Type[] genericTypes = { type, type }; var genericDefaultFactoryMethod = defaultFactoryMethod.MakeGenericMethod(genericTypes); - this.RegisterInternal(type, type, string.Empty, genericDefaultFactoryMethod.Invoke(this, null) as ObjectFactoryBase); + try + { + this.RegisterInternal(type, type, string.Empty, genericDefaultFactoryMethod.Invoke(this, null) as ObjectFactoryBase); + } + catch (MethodAccessException) + { + // Ignore methods we can't access - added for Silverlight + } } var abstractInterfaceTypes = from type in types @@ -1654,7 +1665,14 @@ { Type[] genericTypes = { type, firstImplementation }; var genericDefaultFactoryMethod = defaultFactoryMethod.MakeGenericMethod(genericTypes); - this.RegisterInternal(type, firstImplementation, string.Empty, genericDefaultFactoryMethod.Invoke(this, null) as ObjectFactoryBase); + try + { + this.RegisterInternal(type, firstImplementation, string.Empty, genericDefaultFactoryMethod.Invoke(this, null) as ObjectFactoryBase); + } + catch (MethodAccessException) + { + // Ignore methods we can't access - added for Silverlight + } } } }