コード例 #1
0
        /// <summary>
        /// Invokes a method using the await keyword
        /// if the method returns Task,
        /// otherwise synchronously invokes the method.
        /// </summary>
        /// <param name="isSync">Is client calling this synchronously</param>
        /// <param name="attributeType">Data portal operation attribute</param>
        /// <param name="parameters">
        /// Parameters to pass to method.
        /// </param>
        public async Task CallMethodTryAsyncDI(bool isSync, Type attributeType, params object[] parameters)
        {
            var method = ServiceProviderMethodCaller.FindDataPortalMethod(
                Instance, attributeType, parameters);

            try
            {
                Utilities.ThrowIfAsyncMethodOnSyncClient(isSync, method);
                await ServiceProviderMethodCaller.CallMethodTryAsync(Instance, method, parameters);
            }
            catch (CallMethodException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CallMethodException(Instance.GetType().Name + "." + method.Name + " " + Resources.MethodCallFailed, ex);
            }
        }
コード例 #2
0
ファイル: LateBoundObject.cs プロジェクト: wasiuddin7/csla
        /// <summary>
        /// Invokes a method using the await keyword
        /// if the method returns Task,
        /// otherwise synchronously invokes the method.
        /// </summary>
        /// <param name="isSync">Is client calling this synchronously</param>
        /// <param name="parameters">
        /// Parameters to pass to method.
        /// </param>
        public async Task CallMethodTryAsyncDI <T>(bool isSync, params object[] parameters)
            where T : DataPortalOperationAttribute
        {
            var method = ServiceProviderMethodCaller.FindDataPortalMethod <T>(
                Instance, parameters);

            try
            {
                Utilities.ThrowIfAsyncMethodOnSyncClient(isSync, method);
                await ServiceProviderMethodCaller.CallMethodTryAsync(Instance, method, parameters).ConfigureAwait(false);
            }
            catch (CallMethodException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new CallMethodException(Instance.GetType().Name + "." + method.Name + " " + Resources.MethodCallFailed, ex);
            }
        }