示例#1
0
        public bool Add(T method, bool isExtension)
        {
            if (method.IsDefined(typeof(JSCFunctionAttribute), false))
            {
                if (!method.IsStatic || _cfunc != null)
                {
                    return(false);
                }
                this._cfunc = method;
                return(true);
            }

            var parameters = method.GetParameters();
            var nargs      = BindingManager.GetTSParameterCount(parameters);
            var isVararg   = Binding.Values.IsVarargParameter(parameters);
            MethodBaseVariant <T> variant;

            if (isVararg)
            {
                nargs--;
            }

            if (isExtension)
            {
                nargs--;
            }

            if (!this.variants.TryGetValue(nargs, out variant))
            {
                variant = new MethodBaseVariant <T>(nargs);
                this.variants.Add(nargs, variant);
            }

            _count++;
            variant.Add(method, isVararg, isExtension);
            return(true);
        }