// Entrypoint to the pipeline protected virtual void ExecuteBridgePipeline() { // Make the calls to all other bridge methods first BridgeMethodInfo methodInfo = GetMethodInfoForCall(BridgeRequest.Method); foreach (BridgeChainRequestInfo callInfo in methodInfo.BridgeChainRequests) { Dictionary <string, object> args = new Dictionary <string, object>(); ResolveParameters(callInfo.Parameters, args, Context); BridgeRequest request = new BridgeRequest(callInfo.Method, args); object results = BridgeHandler.Invoke(callInfo.BridgeUrl, request); Context.ResultsChain[callInfo.Name] = results; } TransformRequest(); // Stop execution if we have a cache hit if (ResolveRequestCache()) { return; } ProcessRequest(); TransformResponse(); UpdateResponseCache(); }
public virtual void ProcessRequest() { // Resolve the url before we make the call // If the ServiceUrl is specified on the BridgeRequest, use that instead string url = BridgeRequest.ServiceUrl; if (string.IsNullOrEmpty(url)) { url = BridgeService.ServiceInfo.ServiceUrl; } // Now handle expressions if (!string.IsNullOrEmpty(url)) { url = BridgeHandler.TryParseExpression(url, Context) as string; if (url == null) { throw new ArgumentException("The expression for url must evaluate to a string object."); } } // For now we special case the REST proxy if (string.Equals(BridgeService.ServiceInfo.ServiceClass, "Microsoft.Web.Preview.Services.BridgeRestProxy")) { ServiceResponse.Response = BridgeRestProxy.MakeRestCall(url, ServiceRequest.Args, ServiceRequest.Credentials); } else { // This method gets code gen'ed to call the actual proxy method (see BridgeBuildProvider.cs) ServiceResponse.Response = CallServiceClassMethod(ServiceRequest.Method, ServiceRequest.Args, ServiceRequest.Credentials, url); } }
public static object Invoke(string bridgeUrl, BridgeRequest request) { bridgeUrl = VirtualPathUtility.ToAbsolute(bridgeUrl); Type type = BuildManager.GetCompiledType(bridgeUrl); if (type == null || !typeof(BridgeHandler).IsAssignableFrom(type)) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, PreviewWeb.BridgeHandler_CannotLoad, bridgeUrl)); } BridgeHandler bridge = Activator.CreateInstance(type) as BridgeHandler; if (bridge == null) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, PreviewWeb.BridgeHandler_CannotCreate, bridgeUrl)); } return(bridge.Invoke(request)); }