2929
3030using System ;
3131using System . Collections . Generic ;
32+ using System . Security . Cryptography . X509Certificates ;
3233using System . Threading ;
3334using System . Threading . Tasks ;
3435
@@ -39,9 +40,21 @@ namespace Opc.Ua.Client
3940 /// </summary>
4041 public class DefaultSessionFactory : ISessionFactory
4142 {
43+ /// <summary>
44+ /// The default instance of the factory.
45+ /// </summary>
46+ public static readonly DefaultSessionFactory Instance = new DefaultSessionFactory ( ) ;
47+
48+ /// <summary>
49+ /// Force use of the default instance.
50+ /// </summary>
51+ protected DefaultSessionFactory ( )
52+ {
53+ }
54+
4255 #region Public Methods
4356 /// <inheritdoc/>
44- public async Task < ISession > CreateAsync (
57+ public async virtual Task < ISession > CreateAsync (
4558 ApplicationConfiguration configuration ,
4659 ConfiguredEndpoint endpoint ,
4760 bool updateBeforeConnect ,
@@ -55,7 +68,7 @@ public async Task<ISession> CreateAsync(
5568 }
5669
5770 /// <inheritdoc/>
58- public async Task < ISession > CreateAsync (
71+ public async virtual Task < ISession > CreateAsync (
5972 ApplicationConfiguration configuration ,
6073 ConfiguredEndpoint endpoint ,
6174 bool updateBeforeConnect ,
@@ -71,7 +84,7 @@ public async Task<ISession> CreateAsync(
7184 }
7285
7386 /// <inheritdoc/>
74- public async Task < ISession > CreateAsync (
87+ public async virtual Task < ISession > CreateAsync (
7588 ApplicationConfiguration configuration ,
7689 ITransportWaitingConnection connection ,
7790 ConfiguredEndpoint endpoint ,
@@ -89,7 +102,7 @@ public async Task<ISession> CreateAsync(
89102 }
90103
91104 /// <inheritdoc/>
92- public async Task < ISession > CreateAsync (
105+ public async virtual Task < ISession > CreateAsync (
93106 ApplicationConfiguration configuration ,
94107 ReverseConnectManager reverseConnectManager ,
95108 ConfiguredEndpoint endpoint ,
@@ -102,7 +115,6 @@ public async Task<ISession> CreateAsync(
102115 CancellationToken ct = default
103116 )
104117 {
105-
106118 if ( reverseConnectManager == null )
107119 {
108120 return await CreateAsync ( configuration , endpoint , updateBeforeConnect ,
@@ -141,7 +153,25 @@ await endpoint.UpdateFromServerAsync(
141153 }
142154
143155 /// <inheritdoc/>
144- public Task < ISession > RecreateAsync ( ISession sessionTemplate )
156+ public virtual ISession Create (
157+ ApplicationConfiguration configuration ,
158+ ITransportChannel channel ,
159+ ConfiguredEndpoint endpoint ,
160+ X509Certificate2 clientCertificate ,
161+ EndpointDescriptionCollection availableEndpoints = null ,
162+ StringCollection discoveryProfileUris = null )
163+ {
164+ return Session . Create ( configuration , channel , endpoint , clientCertificate , availableEndpoints , discoveryProfileUris ) ;
165+ }
166+
167+ /// <inheritdoc/>
168+ public virtual Task < ITransportChannel > CreateChannelAsync ( ApplicationConfiguration configuration , ITransportWaitingConnection connection , ConfiguredEndpoint endpoint , bool updateBeforeConnect , bool checkDomain )
169+ {
170+ return Session . CreateChannelAsync ( configuration , connection , endpoint , updateBeforeConnect , checkDomain ) ;
171+ }
172+
173+ /// <inheritdoc/>
174+ public virtual Task < ISession > RecreateAsync ( ISession sessionTemplate )
145175 {
146176 if ( ! ( sessionTemplate is Session template ) )
147177 {
@@ -152,7 +182,7 @@ public Task<ISession> RecreateAsync(ISession sessionTemplate)
152182 }
153183
154184 /// <inheritdoc/>
155- public Task < ISession > RecreateAsync ( ISession sessionTemplate , ITransportWaitingConnection connection )
185+ public virtual Task < ISession > RecreateAsync ( ISession sessionTemplate , ITransportWaitingConnection connection )
156186 {
157187 if ( ! ( sessionTemplate is Session template ) )
158188 {
0 commit comments