Пример #1
0
        public async Task <IAsyncResult> InvokeAsync(object sender, MethodSignatureDto methodSignature, AppDomain domain,
                                                     object[] arguments = null)
        {
            var taskFactory = new TaskFactory();

            return(await taskFactory.StartNew(async() =>
            {
                var result = (Task)methodSignature.ToMethod(domain).Invoke(sender, arguments);

                if (result.IsFaulted)
                {
                    if (result.Exception != null)
                    {
                        foreach (var exception in result.Exception.InnerExceptions)
                        {
                            _logger.Fatal($"{methodSignature.MethodName} failed to invoke with the following exception: {exception.Message}");
                        }
                    }

                    return;
                }

                if (result.IsCompleted)
                {
                    _logger.Debug($"{methodSignature.MethodName} invoked successfully");
                }

                await result;
            }));
        }
Пример #2
0
        /// <summary>
        /// Serialize MethodSignatureDto object into JSON
        /// </summary>
        /// <param name="methodSignature">The MethodSignatureDto to serialize</param>
        /// <returns>Serialized JSON string if MethodSignatureDto is not null</returns>
        public static string SerializeMethodObject(MethodSignatureDto methodSignature)
        {
            if (methodSignature == null)
            {
                throw new ArgumentNullException(nameof(methodSignature), "The provided methodSignature cannot be null");
            }

            return(JsonConvert.SerializeObject(methodSignature));
        }
Пример #3
0
        public void Invoke(object sender, MethodSignatureDto methodSignature,
                           AppDomain domain, object[] arguments = null)
        {
            try
            {
                methodSignature.ToMethod(domain).Invoke(sender, arguments);

                _logger.Debug($"{methodSignature.MethodName} invoked successfully");
            }
            catch (Exception e)
            {
                _logger.Fatal(e);
            }
        }
Пример #4
0
 public async Task <IAsyncResult> InvokeAsync(object sender, MethodSignatureDto methodSignature, object[] arguments = null)
 {
     return(await InvokeAsync(sender, methodSignature, AppDomain.CurrentDomain, arguments));
 }
Пример #5
0
 public void Invoke(object sender, MethodSignatureDto methodSignature,
                    object[] arguments = null)
 {
     Invoke(sender, methodSignature, AppDomain.CurrentDomain, arguments);
 }