c# - Check if your are in wcf service -
i use wcf service , wonder if can use operationcontract methods caller , service. therefore i'd know best way if code running in application or in service.
like this:
[servicecontract] public interface iservice { [operationcontract] bool servicemethod(string param); } [servicebehavior(concurrencymode = concurrencymode.single, instancecontextmode = instancecontextmode.single, usesynchronizationcontext=false)] public class service : iservice { bool servicemethod(string param) { if(!isinwcfservice) //how this? { //call servicemethod in wcf service } else { //do work } } } since calling program , service knows class, think might easier if both have call 1 method , decides if has forward call service or can work.
thank you!
you can check if inside wcf service checking operationcontext.current, wcf service class comparable httpcontext.current in asp.net:
if (operationcontext.current != null) { // inside wcf } else { // not }
Comments
Post a Comment