wcf - Is there a way to pass parameters to a custom Service Behavior through configuration -


i have multiple wcf services hosted in iis i'm applying same custom service behavior. i'm looking way pass several parameters behavior through configuration, such in behaviorextensions or behavior elements.

if helps, i'm adding custom message inspector in applydispatchbehavior, need pass parameters inspector:

public void applydispatchbehavior(servicedescription servicedescription, servicehostbase servicehostbase) {     foreach (channeldispatcher channeldispatcher in servicehostbase.channeldispatchers)     {         foreach (endpointdispatcher endpointdispatcher in channeldispatcher.endpoints)         {             endpointdispatcher.dispatchruntime.messageinspectors.add(                     new validatingmessageinspector(<custom parameters>));         }     } } 

would creating configuration section in web.config parameters valid? if can read config there , apply it, or use appsettings if parameters basic.

for example, if have few parameters of basic types, maybe simple approach be:

<appsettings>     <add key="shared.commonparameter" value="a value" />     <add key="service1.oneparameter" value="false" />     <add key="service1.anotherparameter" value="some value" />     <add key="service2.adifferentparameter" value="42" /> </appsettings> 

that way easy differentiate setting belongs service (notice service name prefix in key), , have shared parameters if needed.

if need more complex in structure might want defining custom configuration sections each service, shown here: http://msdn.microsoft.com/en-us/library/2tw134k3%28v=vs.140%29.aspx

but might overkill, depending on needs , expected flexibility.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -