Created
November 2, 2011 09:43
-
-
Save samoshkin/1333273 to your computer and use it in GitHub Desktop.
Adding operations to WCF service on runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static OperationDescription[] AddHelpOperations(ContractDescription contractDescription, DispatchRuntime dispatchRuntime) | |
{ | |
Fx.Assert(contractDescription != null, "The 'contractDescription' parameter should not be null."); | |
Fx.Assert(dispatchRuntime != null, "The 'dispatchRuntime' parameter should not be null."); | |
Uri baseAddress = dispatchRuntime.EndpointDispatcher.EndpointAddress.Uri; | |
HelpPage helpPage = new HelpPage(baseAddress, null, contractDescription); | |
HttpOperationDescription helpPageOperation = new HttpOperationDescription(HelpPage.HelpMethodName, contractDescription); | |
helpPageOperation.Behaviors.Add(new WebGetAttribute() { UriTemplate = HelpPage.OperationListHelpPageUriTemplate }); | |
helpPageOperation.InputParameters.Add(HttpParameter.RequestMessage); | |
helpPageOperation.ReturnValue = HttpParameter.ResponseMessage; | |
HttpOperationDescription operationhelpPageOperation = new HttpOperationDescription(HelpPage.HelpOperationMethodName, contractDescription); | |
operationhelpPageOperation.Behaviors.Add(new WebGetAttribute() { UriTemplate = HelpPage.OperationHelpPageUriTemplate }); | |
operationhelpPageOperation.InputParameters.Add(HttpParameter.RequestMessage); | |
operationhelpPageOperation.InputParameters.Add(new HttpParameter("operation", TypeHelper.StringType)); | |
operationhelpPageOperation.ReturnValue = HttpParameter.ResponseMessage; | |
dispatchRuntime.Operations.Add( | |
new DispatchOperation(dispatchRuntime, HelpPage.HelpMethodName, null, null) { Invoker = helpPage.GetHelpPageInvoker(true) }); | |
dispatchRuntime.Operations.Add( | |
new DispatchOperation(dispatchRuntime, HelpPage.HelpOperationMethodName, null, null) { Invoker = helpPage.GetHelpPageInvoker(false) }); | |
return new OperationDescription[] { helpPageOperation.ToOperationDescription(), operationhelpPageOperation.ToOperationDescription() }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment