/// <summary> /// Adjusts the contract and behavior of each operation that returns <see cref="System.IObservable{T}"/>. /// </summary> /// <param name="contractDescription">The contract description to be modified.</param> /// <param name="endpoint">The endpoint that exposes the contract.</param> /// <param name="dispatchRuntime">The dispatch runtime that controls service execution.</param> public void ApplyDispatchBehavior(ContractDescription contractDescription, ServiceEndpoint endpoint, DispatchRuntime dispatchRuntime) { Contract.Assume(contractDescription != null); foreach (var operation in contractDescription.Operations) { Contract.Assume(operation != null); if (ObservableMethodInvoker.IsObservableMethod(operation.SyncMethod)) { InitializeObservableOperation(operation, ReturnAsListDefault); } } }
/// <summary> /// Ensures that the method to which this attribute is applied is synchronous and returns <see cref="System.IObservable{T}"/>. /// </summary> /// <param name="operationDescription">The operation being examined. Use for examination only. If the operation /// description is modified, the results are undefined.</param> public void Validate(OperationDescription operationDescription) { Contract.Assume(operationDescription != null); if (operationDescription.SyncMethod == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Errors.OperationIsNotSynchronous, operationDescription.Name)); } if (!ObservableMethodInvoker.IsObservableMethod(operationDescription.SyncMethod)) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Errors.OperationIsNotObservable, operationDescription.Name)); } }