I want to create a framework , which should be configurable through App.config.
just like our WCF Host
To make it clear
I need to only write the 3 line to host the service with the below configuration
Type serviceType = typeof(DerivativesCalculatorServiceType);
ServiceHost host = new ServiceHost(serviceType))
host.Open();
WCF configuration
<configuration>
<system.serviceModel>
<services>
<service name="DerivativesCalculator.DerivativesCalculatorServiceType"
behaviorConfiguration="DerivativesCalculatorService">
<endpoint address="Calculator"
binding="basicHttpBinding"
contract="DerivativesCalculator.IDerivativesCalculator"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DerivativesCalculatorService">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I want to know how is the binding object, endpoint object, Contract created internally by parsing the xml, because xml is strings, how is the corresponding objects or class created internally.
For example AddServiceEndpoint
AddServiceEndpoint(typeof(IDerivativesCalculator), basicHttpBindingObject, Address);
how is DerivativesCalculator.IDerivativesCalculator from converted to IDerivativesCalculator
DerivativesCalculator.IDerivativesCalculatorin the XML specifies the name of the interface that defines the contract.IDerivativesCalculatoris the actual interface, that is defined in theDerivativesnamespace.Reflection is used to find a type in the assembly. The Assembly.GetType(String) method is an example of a reflection method. This method can be used to return the
IDerivativesCalculatortype, by passing theDerivativesCalculator.IDerivativesCalculatorname to the method.Reflection can also be used to create instances of a type, again based on just the name of the type. This is how you can populate an object based on a configuration file.