private TCecil GetMemberItemFromCache <TCecil, TReflector>(object item, Dictionary <TReflector, TCecil> cache, FindMatchingMember <TCecil, TReflector> finder) where TReflector : RC.IMemberReference { if (!(item is TReflector)) { throw new ArgumentException(typeof(TReflector).Name); } TReflector memberdec = (TReflector)item; TCecil result = default(TCecil); if ((memberdec != null) && (!cache.ContainsKey(memberdec))) { ITypeDeclaration classdec = (ITypeDeclaration)memberdec.DeclaringType; TypeDefinition typedef = ReflectorHelper.FindMatchingType(AssemblyDefinition, classdec); if (typedef != null) { result = finder(typedef, memberdec); if (result != null) { // add result to cache cache.Add(memberdec, result); } } } else { // Definition is already cached result = cache[memberdec]; } return(result); }
public TypeDefinition GetTypeDefinition(ITypeDeclaration item) { return(TryGetOrAdd(_typecache, item, tdef => ReflectorHelper.FindMatchingType(AssemblyDefinition, tdef))); }