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

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -