public Exception ThrowHelperInternal(bool fatal) { return(fatal ? Fx.AssertAndThrowFatal("Fatal InternalException should never be thrown.") : Fx.AssertAndThrow("InternalException should never be thrown.")); }
public static void End(IAsyncResult result) { Fx.AssertAndThrowFatal(result.IsCompleted, "CompletedAsyncResult was not completed!"); AsyncResult.End <CompletedAsyncResult>(result); }
private static void BindOperations(ContractDescription contract, ClientRuntime proxy, DispatchRuntime dispatch) { if (!(((proxy == null) != (dispatch == null)))) { throw Fx.AssertAndThrowFatal("DispatcherBuilder.BindOperations: ((proxy == null) != (dispatch == null))"); } MessageDirection local = (proxy == null) ? MessageDirection.Input : MessageDirection.Output; for (int i = 0; i < contract.Operations.Count; i++) { OperationDescription operation = contract.Operations[i]; MessageDescription first = operation.Messages[0]; if (first.Direction != local) { if (proxy == null) { proxy = dispatch.CallbackClientRuntime; } ClientOperation proxyOperation = proxy.Operations[operation.Name]; Fx.Assert(proxyOperation != null, ""); for (int j = 0; j < operation.Behaviors.Count; j++) { IOperationBehavior behavior = operation.Behaviors[j]; behavior.ApplyClientBehavior(operation, proxyOperation); } } else { if (dispatch == null) { dispatch = proxy.CallbackDispatchRuntime; } DispatchOperation dispatchOperation = null; if (dispatch.Operations.Contains(operation.Name)) { dispatchOperation = dispatch.Operations[operation.Name]; } if (dispatchOperation == null && dispatch.UnhandledDispatchOperation != null && dispatch.UnhandledDispatchOperation.Name == operation.Name) { dispatchOperation = dispatch.UnhandledDispatchOperation; } if (dispatchOperation != null) { for (int j = 0; j < operation.Behaviors.Count; j++) { IOperationBehavior behavior = operation.Behaviors[j]; behavior.ApplyDispatchBehavior(operation, dispatchOperation); } for (int k = 0; k < operation.AuthorizeOperation.Count; k++) { IAuthorizeOperation authorizeOperation = operation.AuthorizeOperation[k]; authorizeOperation.BuildClaim(operation, dispatchOperation); } } } } }
public IEnumerator <KeyValuePair <MessageQuery, TResult> > GetEnumerator() { QueryProcessor processor = this.matcher.CreateProcessor(); Collection <KeyValuePair <MessageQuery, XPathResult> > results = new Collection <KeyValuePair <MessageQuery, XPathResult> >(); processor.ResultSet = results; try { processor.Eval(this.matcher.RootOpcode, this.message, this.evalBody); if (typeof(TResult) == typeof(XPathResult)) { return((IEnumerator <KeyValuePair <MessageQuery, TResult> >)(object) results.GetEnumerator()); } else if (typeof(TResult) == typeof(string) || typeof(TResult) == typeof(bool) || typeof(TResult) == typeof(object)) { Collection <KeyValuePair <MessageQuery, TResult> > typedResults = new Collection <KeyValuePair <MessageQuery, TResult> >(); foreach (var result in results) { if (typeof(TResult) == typeof(string)) { typedResults.Add( new KeyValuePair <MessageQuery, TResult>( result.Key, (TResult)(object)result.Value.GetResultAsString())); } else if (typeof(TResult) == typeof(bool)) { typedResults.Add( new KeyValuePair <MessageQuery, TResult>( result.Key, (TResult)(object)result.Value.GetResultAsBoolean())); } else { typedResults.Add(new KeyValuePair <MessageQuery, TResult>( result.Key, (TResult)(object)result.Value)); } } return((IEnumerator <KeyValuePair <MessageQuery, TResult> >)typedResults.GetEnumerator()); } else { throw Fx.AssertAndThrowFatal("unsupported type"); } } catch (XPathNavigatorException e) { throw TraceUtility.ThrowHelperError(e.Process(this.matcher.RootOpcode), this.message); } catch (NavigatorInvalidBodyAccessException e) { throw TraceUtility.ThrowHelperError(e.Process(this.matcher.RootOpcode), this.message); } finally { if (this.evalBody) { this.message.Close(); } this.matcher.ReleaseProcessor(processor); } }