Language: C#
Resolve the MEF bug
//this is the MEF Team Code namespace System.ComponentModel.Composition.AttributedModel { internal class AttributedPartCreationInfo : IReflectionPartCreationInfo { private IEnumerable<MemberInfo> GetImportMembers(Type type) { if (type.IsAbstract) { yield break; } foreach (MemberInfo member in GetDeclaredOnlyImportMembers(type)) { yield return member; } // Walk up the type chain until you hit object. if (type.BaseType != null) { Type baseType = type.BaseType; // Stopping at object instead of null to help with performance. It is a noticable performance // gain (~5%) if we don't have to try and pull the attributes we know don't exist on object. // We also need the null check in case we're passed a type that doesn't live in the runtime context. while (baseType != null && baseType != CompositionServices.ObjectType) { foreach (MemberInfo member in GetDeclaredOnlyImportMembers(baseType)) { yield return member; } baseType = baseType.BaseType; } } } } } //******************** //this my code to Resolve the mef bug namespace System.ComponentModel.Composition.AttributedModel { internal class AttributedPartCreationInfo : IReflectionPartCreationInfo { private IEnumerable<MemberInfo> GetImportMembers(Type type) { if (type.IsAbstract) { yield break; } var typeStack = new Stack<Type>(); typeStack.Push(type); if (type.BaseType != null) { Type baseType = type.BaseType; typeStack.Push(baseType); while (baseType != null && baseType != CompositionServices.ObjectType) { baseType = baseType.BaseType; typeStack.Push(baseType); } } while (typeStack.Count>0) { var checkType = typeStack.Pop(); foreach (MemberInfo member in GetDeclaredOnlyImportMembers(checkType)) { yield return member; } } } } }
Tags:
Description:
this is the resolve of the scenario here: http://codepaste.net/ca3epq
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

