Beispiel #1
0
        public ExternalFunction(ExternalFunctionDelegate @delegate)
        {
            if (_length == null)
            {
                _length = new Number(0)
                {
                    _attributes = JSValueAttributesInternal.ReadOnly | JSValueAttributesInternal.DoNotDelete | JSValueAttributesInternal.DoNotEnumerate
                }
            }
            ;

#if (PORTABLE || NETCORE)
            var paramCountAttrbt = @delegate.GetMethodInfo().GetCustomAttributes(typeof(ArgumentsCountAttribute), false).ToArray();
#else
            var paramCountAttrbt = @delegate.Method.GetCustomAttributes(typeof(ArgumentsCountAttribute), false);
#endif
            _length._iValue = paramCountAttrbt.Length > 0 ? ((ArgumentsCountAttribute)paramCountAttrbt[0]).Count : 1;

            if (@delegate == null)
            {
                throw new ArgumentNullException();
            }

            _delegate = @delegate;
            RequireNewKeywordLevel = BaseLibrary.RequireNewKeywordLevel.WithoutNewOnly;
        }
Beispiel #2
0
        public ExternalFunction(ExternalFunctionDelegate del)
        {
            if (_length == null)
                _length = new Number(0) { attributes = JSObjectAttributesInternal.ReadOnly | JSObjectAttributesInternal.DoNotDelete | JSObjectAttributesInternal.DoNotEnum };
            
#if PORTABLE
            var paramCountAttrbt = del.GetMethodInfo().GetCustomAttributes(typeof(ArgumentsLengthAttribute), false).ToArray();
#else
            var paramCountAttrbt = del.Method.GetCustomAttributes(typeof(ArgumentsLengthAttribute), false);
#endif
            _length.iValue = paramCountAttrbt != null && paramCountAttrbt.Length > 0 ? ((ArgumentsLengthAttribute)paramCountAttrbt[0]).Count : 1;
            _prototype = undefined;
            if (del == null)
                throw new ArgumentNullException();
            this.del = del;
        }