Beispiel #1
0
        public override int FindMethod(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    if (_dispatchedType != null)
                    {
                        var memberInfo = _dispatchedType.GetMember(name);
                        if (memberInfo.Length == 0 || !(memberInfo[0].MemberType == MemberTypes.Method || memberInfo[0].MemberType == MemberTypes.Property))
                        {
                            throw RuntimeException.MethodNotFoundException(name);
                        }
                        else
                        {
                            _membersCache.Add(dispId, memberInfo[0]);
                            _dispIdCache.Add(name, dispId);
                        }
                    }
                    else
                    {
                        _dispIdCache.Add(name, dispId);
                    }
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }
            }

            return(dispId);
        }
        public override void CallAsFunction(int methodNumber, IValue[] arguments, out IValue retValue)
        {
            var method = _methods[methodNumber];

            if (!(method.IsFunction ?? true))
            {
                throw RuntimeException.UseProcAsAFunction();
            }

            var dispId = method.DispatchId;

            try
            {
                try
                {
                    var result = DispatchUtility.Invoke(Instance, dispId, MarshalArguments(arguments));
                    retValue = CreateIValue(result);
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    throw e.InnerException ?? e;
                }
            }
            catch (System.MissingMemberException)
            {
                throw RuntimeException.MethodNotFoundException(method.Name);
            }
        }
        public override int FindMethod(string name)
        {
            if (!TryFindMethod(name, out var md))
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(_methods.IndexOf(md));
        }
        public int FindMethod(string name)
        {
            var methodNumber = NativeApiProxy.FindMethod(_object, name);

            if (methodNumber < 0)
            {
                throw RuntimeException.MethodNotFoundException(name);
            }
            return(methodNumber);
        }
Beispiel #5
0
        public override int FindMethod(string name)
        {
            var idx = FindMemberIndex(name);

            if (idx < 0)
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(idx);
        }
        public Action <IValue[]> GetMethodExecutor(string methodName)
        {
            var id = GetScriptMethod(methodName);

            if (id == -1)
            {
                throw RuntimeException.MethodNotFoundException(methodName, AsString());
            }

            return((args) => CallScriptMethod(id, args));
        }
Beispiel #7
0
 public override int FindMethod(string name)
 {
     if (name.ToLower() == "количество")
     {
         return(0);
     }
     else
     {
         throw RuntimeException.MethodNotFoundException(name);
     }
 }
Beispiel #8
0
        public int FindMethod(string name)
        {
            InitSearch();

            if (!_methodNumbers.TryGetValue(name, out var idx))
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(idx);
        }
        public int FindMethod(string name)
        {
            int id;

            if (!_thisMethIndexes.TryGetIdOfName(name, out id))
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(id);
        }
Beispiel #10
0
        public int FindMethod(string name)
        {
            name = name.ToLower();
            var idx = _methodPtrs.FindIndex(x => x.methodInfo.Name == name || x.methodInfo.Alias == name);

            if (idx < 0)
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(idx);
        }
        /// <summary>
        /// Основная нагрузка, выполняет метод ОбработкаВызова посредника
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task InvokeAsync(HttpContext context)
        {
            _context = context;
            var mId = GetScriptMethod("ОбработкаВызова");

            if (mId == -1)
            {
                throw RuntimeException.MethodNotFoundException("ОбработкаВызова");
            }
            HttpRequest  = new HttpRequestImpl(_context.Request);
            HttpResponse = new HttpResponseImpl(_context.Response);

            await RunMethodInAsync(context, mId);
        }
        /// <summary>
        /// Основная нагрузка, выполняет метод ОбработкаВызова посредника
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task InvokeAsync(HttpContext context)
        {
            _context = context;
            var mId = GetScriptMethod("ОбработкаВызова");

            if (mId == -1)
            {
                throw RuntimeException.MethodNotFoundException("ОбработкаВызова");
            }
            HttpRequest  = new HttpRequestImpl(_context.Request);
            HttpResponse = new HttpResponseImpl(_context.Response);

            var parameters = new IValue[] { new ArrayImpl() };
            await Task.Run(() => CallScriptMethod(mId, parameters));
        }
 public override void CallAsProcedure(int methodNumber, IValue[] arguments)
 {
     try
     {
         try
         {
             DispatchUtility.Invoke(_instance, methodNumber, MarshalArguments(arguments));
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             throw e.InnerException;
         }
     }
     catch (System.MissingMemberException)
     {
         throw RuntimeException.MethodNotFoundException("dispid[" + methodNumber.ToString() + "]");
     }
 }
        public override int FindMethod(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    _dispIdCache.Add(name, dispId);
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }
            }

            return(dispId);
        }
 public override void CallAsFunction(int methodNumber, IValue[] arguments, out IValue retValue)
 {
     try
     {
         try
         {
             var result = DispatchUtility.Invoke(_instance, methodNumber, MarshalArguments(arguments));
             retValue = CreateIValue(result);
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             throw e.InnerException;
         }
     }
     catch (System.MissingMemberException)
     {
         throw RuntimeException.MethodNotFoundException("dispid[" + methodNumber.ToString() + "]");
     }
 }
Beispiel #16
0
        public int FindMethod(string name)
        {
            Init();

            // поскольку этот метод вызывается довольно часто, то тут
            // возможна некоторая просадка по производительности
            // за счет сравнения IgnoreCase вместо обычного "числового" сравнения
            // Надо будет понаблюдать или вообще замерить
            //
            var idx = _methodPtrs.FindIndex(x =>
                                            String.Compare(x.MethodInfo.Name, name, StringComparison.OrdinalIgnoreCase) == 0 ||
                                            String.Compare(x.MethodInfo.Alias, name, StringComparison.OrdinalIgnoreCase) == 0);

            if (idx < 0)
            {
                throw RuntimeException.MethodNotFoundException(name);
            }

            return(idx);
        }
        public override int FindMethod(string name)
        {
            var idx = FindOwnMethod(name);

            if (idx >= 0)
            {
                return(idx);
            }
            else
            {
                int index;
                if (_methodSearchCache.TryGetValue(name, out index))
                {
                    return(index);
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name, _module.ModuleInfo.ModuleName);
                }
            }
        }
        public override void CallAsProcedure(int methodNumber, IValue[] arguments)
        {
            var method = _methods[methodNumber];

            var dispId = method.DispatchId;

            try
            {
                try
                {
                    DispatchUtility.Invoke(Instance, dispId, MarshalArguments(arguments));
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    throw e.InnerException ?? e;
                }
            }
            catch (System.MissingMemberException)
            {
                throw RuntimeException.MethodNotFoundException(method.Name);
            }
        }
Beispiel #19
0
        public override int FindMethod(string name)
        {
            var idx = FindOwnMethod(name);

            if (idx >= 0)
            {
                return(idx);
            }
            else
            {
                var methFound = _module.ExportedMethods.Where(x => String.Compare(x.SymbolicName, name, true) == 0)
                                .Select(x => x.Index).ToArray();
                if (methFound.Length > 0)
                {
                    return(methFound[0]);
                }
                else
                {
                    throw RuntimeException.MethodNotFoundException(name);
                }
            }
        }
Beispiel #20
0
        private int FindInternalMethod(string handler)
        {
            // TODO: нет адекватного API для поиска неэкспортного метода (прямо как в ОбработкеОповещения 1С)
            int handlerIndex = -1;
            var mCount       = GetMethodsCount();

            for (int i = 0; i < mCount; i++)
            {
                var mi = GetMethodInfo(i);
                if (StringComparer.OrdinalIgnoreCase.Compare(mi.Name, handler) == 0)
                {
                    handlerIndex = i;
                    break;
                }
            }

            if (handlerIndex < 0)
            {
                throw RuntimeException.MethodNotFoundException(handler);
            }
            return(handlerIndex);
        }
 public virtual int FindMethod(string name)
 {
     throw RuntimeException.MethodNotFoundException(name);
 }