示例#1
0
        public TDelegate Build()
        {
            var parameterTypesForCache = _explicitParameterTypes;

            if (parameterTypesForCache == null)
            {
                parameterTypesForCache = Interception.ParamsToTypes(_parameters);
            }

            var cacheKey = new Key(
                callingModule: _resolutionModule,
                mdToken: _mdToken,
                callOpCode: _opCode,
                concreteType: _concreteType,
                explicitParameterTypes: parameterTypesForCache,
                methodGenerics: _methodGenerics,
                declaringTypeGenerics: _declaringTypeGenerics);

            return(Cache.GetOrAdd(cacheKey, key =>
            {
                // Validate requirements at the last possible moment
                // Don't do more than needed before checking the cache
                ValidateRequirements();
                return EmitDelegate();
            }));
        }
示例#2
0
        public MethodBuilder <TDelegate> WithParameters(params object[] parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            return(WithParameters(Interception.ParamsToTypes(parameters)));
        }