--- myst: substitutions: method: |- ```{image} /img/code_reference/net_library/method.ico ``` prop: |- ```{image} /img/code_reference/net_library/prop.ico ``` --- # ConnectionSettings Class ```{toctree} :glob: :hidden: connectionsettings/* ``` Settings used to connect with the ERP Service. **Namespace:** powerGate.Erp.Client\ **Assembly:** powerGate.Erp.Client.dll ## Inheritance Hierarchy [System.Object]()\  **powerGate.Erp.Client.ConnectionSettings** ## Syntax ```{code-block} CSharp :linenos: public class ConnectionSettings ``` The ConnectionSettings type exposes the following members. ## Constructors | Name | Description | |---------------------------------|-------------------------------------------------------------| | {{method}} ConnectionSettings() | Initializes a new instance of the ConnectionSettings class. | ## Properties | Type | Name | Description | |------------------------------------------|--------------------|---------------------------------------------------------------------------------------------------------| | {{prop}} [Uri][] | Service | Gets or sets the Url of the service to connect with. | | {{prop}} [ICredentials][] | Credentials | Gets or sets the credentials to connect with the services. | | {{prop}} bool | IgnoreCertificates | Gets or sets the property whether to trust all certificates. | | {{prop}} Action\<[ErpClientSettings][]\> | OnConnect | Gets or sets the [Action][] which will be invoked before connecting to the service. More details below. | [Uri]: https://msdn.microsoft.com/en-us/library/system.uri(v=vs.110).aspx [ICredentials]: https://msdn.microsoft.com/en-us/library/system.net.icredentials%28v=vs.110%29.aspx [ErpClientSettings]: /code_reference/net_library/erpclientsettings [Action]: https://msdn.microsoft.com/en-us/library/018hxwa8%28v=vs.110%29.aspx ## Remarks The **OnConnect**-Action will be executed before connecting to the service.\ In case of the CatalogService, the OnConnect will be called for each service it connects to.\ Setting the Action will allow you to manipulate certain [settings]() or even attaching to the BeforeRequest/AfterResponse handler. ## Examples The following example creates an instance of the ConnectionSettings class. **Create settings with Credentials** ```{code-block} CSharp :linenos: var connectionSettings = new ConnectionSettings { Service = new Uri("http://services.odata.org/V4/Northwind/Northwind.svc"), Credentials = new NetworkCredential("MyUserName", "1234"), IgnoreCertificates = true }; ``` **Create settings using the OnConnect property to add a header to each request** ```{code-block} CSharp :linenos: var connectionSettings = new ConnectionSettings { Service = new Uri("http://services.odata.org/V4/Northwind/Northwind.svc"), OnConnect = settings => { //Set a 5 seconds request timeout settings.RequestTimeout = TimeSpan.FromSeconds(5); //Add header to each request settings.BeforeRequest = requestMessage => { requestMessage.Headers.Add("Accept", "application/json"); }; } }; ``` ## See also **Reference** - [powerGate.Erp.Client namespace]()