private Type GetDelegateType(MetaMethod method, ClassEmitter @class, ProxyGenerationOptions options) { var scope = @class.ModuleScope; var key = new CacheKey( typeof(Delegate), targetType, new[] { method.MethodOnTarget.ReturnType } .Concat(ArgumentsUtil.GetTypes(method.MethodOnTarget.GetParameters())). ToArray(), null); var type = scope.GetFromCache(key); if (type != null) { return(type); } type = new DelegateTypeGenerator(method, targetType) .Generate(@class, options, namingScope) .BuildType(); scope.RegisterInCache(key, type); return(type); }
private Type GetDelegateType(MetaMethod method, ClassEmitter @class) { var scope = @class.ModuleScope; var key = new CacheKey( typeof(Delegate), targetType, new[] { method.MethodOnTarget.ReturnType } .Concat(ArgumentsUtil.GetTypes(method.MethodOnTarget.GetParameters())). ToArray(), null); return(scope.TypeCache.GetOrAddWithoutTakingLock(key, _ => new DelegateTypeGenerator(method, targetType) .Generate(@class, namingScope) .BuildType())); }