public bool FindMemberTracker(string memberName, out IHappyTracker result) { lock (_members) { IHappyTracker tracker; if(!_members.TryGetValue(memberName, out tracker)) { MemberInfo[] memberInfos = _myType.GetMember(memberName); if(memberInfos.Length == 0) { result = null; return false; } MemberInfo found = memberInfos[0]; if(found is MethodInfo) //<--if the first memberInfo is a MethodInfo, they all are MethodInfo tracker = new HappyMethodTracker(this, memberName, (from m in memberInfos select (MethodInfo)m).ToArray()); else if(found is PropertyInfo || found is FieldInfo) { DebugAssert.IsTrue(memberInfos.Length == 1, "I think I found {0} PropertyInfos. I really just wanted 1.", memberInfos.Length); tracker = new HappyPropertyOrFieldTracker(memberName, found); } else if(found is Type) tracker = new HappyTypeTracker((Type)found); else throw new UnhandledCaseException(); _members[memberName] = tracker; } result = tracker; } return true; }
public HappyMethodTracker(HappyTypeTracker typeTracker, string name, MethodInfo[] methods) { this.Methods = methods; _typeTracker = typeTracker; this.Name = name; }