I have an app.config file. It's from a sample given to me for an API I have to use... I want to get a setting from the file so that I can use the settings from there and not have to duplicate efforts.
How can I get the words "FindMe", "LocalMachine" and "My" in this app.config file (to drive pulling a certificate from the given information)?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>...</startup>
<system.serviceModel>
<bindings>...</bindings>
<client>...</client>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCertificateBehavior">
<clientCredentials>
<clientCertificate findValue="FindMe" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
<serviceCertificate><authentication certificateValidationMode="None"/></serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I'm looking to see if I can find it in System.ServiceModel.Configuration or ConfigurationManager, but I'm not seeing how to get those specific values.
Edit:
I think I'm real close, but I can't seem to get the values.
Using Gandarez's comment and Phils answer as a launching board, I was able to poke my way into this solution. It's far from finished, but it'll allow me to get the values and I can fine tune it as needed:
Once you have access to the
ServiceModelSectionGroup
, you can access the various parts of the model. egBehaviors.EndpointBehaviors
collectionWCF section info