Пример #1
0
            /// <summary>
            /// Derived classes override this method to provide custom invocation behavior.
            /// </summary>
            /// <param name="instance">Instance to invoke the invoker against.</param>
            /// <param name="inputs">Input parameters post conversion.</param>
            /// <returns>Result of invocation.</returns>

            protected override async ValueTask <object> InvokeCoreAsync(object instance, object[] inputs)
            {
                ServiceInvokeResult invokeResult;

                try
                {
                    InvokeDescription description = new InvokeDescription(this.operation, inputs);
                    invokeResult = await((DomainService)instance).InvokeAsync(description, CancellationToken.None).ConfigureAwait(false);
                }
                catch (UnauthorizedAccessException ex)
                {
                    throw new DomainDataServiceException((int)System.Net.HttpStatusCode.Unauthorized, ex.Message, ex);
                }
                catch (Exception ex)
                {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    else
                    {
                        throw new DomainDataServiceException(Resource.DomainDataService_General_Error, ex);
                    }
                }

                // This will throw if there are any validation erros
                DomainDataServiceException.HandleValidationErrors(invokeResult.ValidationErrors);
                return(invokeResult.Result);
            }
Пример #2
0
            /// <summary>
            /// Derived classes override this method to provide custom invocation behavior.
            /// </summary>
            /// <param name="instance">Instance to invoke the invoker against.</param>
            /// <param name="inputs">Input parameters post conversion.</param>
            /// <param name="outputs">Optional out parameters.</param>
            /// <returns>Result of invocation.</returns>
            protected override object InvokeCore(object instance, object[] inputs, out object[] outputs)
            {
                outputs = ServiceUtils.EmptyObjectArray;

                IEnumerable <ValidationResult> validationErrors;
                object result;

                try
                {
                    InvokeDescription description = new InvokeDescription(this.operation, inputs);
                    result = ((DomainService)instance).Invoke(description, out validationErrors);
                }
                catch (UnauthorizedAccessException ex)
                {
                    throw new DomainDataServiceException((int)System.Net.HttpStatusCode.Unauthorized, ex.Message, ex);
                }
                catch (Exception ex)
                {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    else
                    {
                        throw new DomainDataServiceException(Resource.DomainDataService_General_Error, ex);
                    }
                }

                DomainDataServiceException.HandleValidationErrors(validationErrors);

                return(result);
            }
            /// <summary>
            /// Derived classes override this method to provide custom invocation behavior.
            /// </summary>
            /// <param name="instance">Instance to invoke the invoker against.</param>
            /// <param name="inputs">Input parameters post conversion.</param>
            /// <param name="outputs">Optional out parameters.</param>
            /// <returns>Result of invocation.</returns>
            protected override object InvokeCore(object instance, object[] inputs, out object[] outputs)
            {
                outputs = ServiceUtils.EmptyObjectArray;

                // DEVNOTE(wbasheer): Need to perform query composition here for query options, potentially
                // need to inject the query options in the message properties somewhere.
                QueryDescription queryDesc = new QueryDescription(this.operation, inputs);

                IEnumerable <ValidationResult> validationErrors;
                int totalCount;
                IEnumerable <TEntity> result;

                try
                {
                    result = (IEnumerable <TEntity>)((DomainService)instance).Query(queryDesc, out validationErrors, out totalCount);
                }
                catch (UnauthorizedAccessException ex)
                {
                    throw new DomainDataServiceException((int)System.Net.HttpStatusCode.Unauthorized, ex.Message, ex);
                }
                catch (Exception ex)
                {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    else
                    {
                        throw new DomainDataServiceException(Resource.DomainDataService_General_Error, ex);
                    }
                }
                DomainDataServiceException.HandleValidationErrors(validationErrors);

                // DEVNOTE(wbasheer): Potentially return something that contains both the sequence and
                // the count value obtained from the query operation.
                return(result);
            }
            /// <summary>
            /// Derived classes override this method to provide custom invocation behavior.
            /// </summary>
            /// <param name="instance">Instance to invoke the invoker against.</param>
            /// <param name="inputs">Input parameters post conversion.</param>
            /// <returns>Result of invocation.</returns>
            protected override async ValueTask <object> InvokeCoreAsync(object instance, object[] inputs)
            {
                // DEVNOTE(wbasheer): Need to perform query composition here for query options, potentially
                // need to inject the query options in the message properties somewhere.
                QueryDescription queryDesc = new QueryDescription(this.operation, inputs);

                IEnumerable <ValidationResult> validationErrors;
                IEnumerable <TEntity>          result;

                try
                {
                    var queryResult = await((DomainService)instance).QueryAsync <TEntity>(queryDesc, CancellationToken.None).ConfigureAwait(false);
                    validationErrors = queryResult.ValidationErrors;
                    result           = (IEnumerable <TEntity>)queryResult.Result;
                }
                catch (UnauthorizedAccessException ex)
                {
                    throw new DomainDataServiceException((int)System.Net.HttpStatusCode.Unauthorized, ex.Message, ex);
                }
                catch (Exception ex)
                {
                    if (ex.IsFatal())
                    {
                        throw;
                    }
                    else
                    {
                        throw new DomainDataServiceException(Resource.DomainDataService_General_Error, ex);
                    }
                }
                DomainDataServiceException.HandleValidationErrors(validationErrors);

                // DEVNOTE(wbasheer): Potentially return something that contains both the sequence and
                // the count value obtained from the query operation.
                return(result);
            }