99using System . ServiceModel . Description ;
1010using Microsoft . PowerPlatform . Dataverse . Client . Model ;
1111using Microsoft . PowerPlatform . Dataverse . Client . Auth ;
12+ using Microsoft . Extensions . Logging ;
1213
1314namespace Microsoft . PowerPlatform . Dataverse . Client
1415{
1516 /// <summary>
16- /// Stores Parsed connection info from the use of a CDS connection string.
17- /// This is only populated when the CDS Connection string object is used, this is read only.
17+ /// Stores Parsed connection info from the use of a CDS connection string.
18+ /// This is only populated when the CDS Connection string object is used, this is read only.
1819 /// </summary>
1920 internal class DataverseConnectionStringProcessor
2021 {
@@ -120,7 +121,7 @@ internal string Password
120121 internal string CertThumbprint { get ; set ; }
121122
122123 /// <summary>
123- /// if set to true, then the org URI should be used directly.
124+ /// if set to true, then the org URI should be used directly.
124125 /// </summary>
125126 internal bool SkipDiscovery { get ; set ; }
126127
@@ -188,20 +189,20 @@ public string TokenCacheStorePath
188189 }
189190
190191 /// <summary>
191- /// When true, specifies a unique instance of the connection should be created.
192+ /// When true, specifies a unique instance of the connection should be created.
192193 /// </summary>
193194 public bool UseUniqueConnectionInstance { get ; internal set ; }
194195
195196 /// <summary>
196- /// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197+ /// When set to true and oAuth Mode ( not Cert ) attempts to run the login using the current user identity.
197198 /// </summary>
198199 public bool UseCurrentUser { get ; set ; }
199200
200201 public DataverseConnectionStringProcessor ( )
201202 {
202203 }
203204
204- private DataverseConnectionStringProcessor ( IDictionary < string , string > connection )
205+ private DataverseConnectionStringProcessor ( IDictionary < string , string > connection , ILogger logger )
205206 : this (
206207 connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ServiceUri ) ,
207208 connection . FirstNotNullOrEmpty ( ConnectionStringConstants . UserName ) ,
@@ -218,12 +219,13 @@ private DataverseConnectionStringProcessor(IDictionary<string, string> connectio
218219 connection . FirstNotNullOrEmpty ( ConnectionStringConstants . CertThumbprint ) ,
219220 connection . FirstNotNullOrEmpty ( ConnectionStringConstants . SkipDiscovery ) ,
220221 connection . FirstNotNullOrEmpty ( ConnectionStringConstants . IntegratedSecurity ) ,
221- connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ClientSecret )
222+ connection . FirstNotNullOrEmpty ( ConnectionStringConstants . ClientSecret ) ,
223+ logger
222224 )
223225 {
224226 }
225227 private DataverseConnectionStringProcessor ( string serviceUri , string userName , string password , string domain , string homeRealmUri , string authType , string requireNewInstance , string clientId , string redirectUri ,
226- string tokenCacheStorePath , string loginPrompt , string certStoreName , string certThumbprint , string skipDiscovery , string IntegratedSecurity , string clientSecret )
228+ string tokenCacheStorePath , string loginPrompt , string certStoreName , string certThumbprint , string skipDiscovery , string IntegratedSecurity , string clientSecret , ILogger logger )
227229 {
228230 DataverseTraceLogger logEntry = new DataverseTraceLogger ( ) ;
229231 Uri _serviceuriName , _realmUri ;
@@ -232,7 +234,7 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
232234 if ( bool . TryParse ( skipDiscovery , out tempbool ) )
233235 SkipDiscovery = tempbool ;
234236 else
235- SkipDiscovery = true ; // changed to change defaulting behavior of skip discovery.
237+ SkipDiscovery = true ; // changed to change defaulting behavior of skip discovery.
236238
237239
238240 ServiceUri = GetValidUri ( serviceUri , out _serviceuriName ) ? _serviceuriName : null ;
@@ -247,16 +249,16 @@ private DataverseConnectionStringProcessor(string serviceUri, string userName, s
247249 CertStoreName = certStoreName ;
248250 CertThumbprint = certThumbprint ;
249251
250- // Check to see if use current user is configured.
252+ // Check to see if use current user is configured.
251253 bool _IntegratedSecurity = false ;
252254 if ( ! string . IsNullOrEmpty ( IntegratedSecurity ) )
253255 bool . TryParse ( IntegratedSecurity , out _IntegratedSecurity ) ;
254256
255- bool useUniqueConnection = true ; // Set default to true to follow the old behavior.
257+ bool useUniqueConnection = true ; // Set default to true to follow the old behavior.
256258 if ( ! string . IsNullOrEmpty ( requireNewInstance ) )
257259 bool . TryParse ( requireNewInstance , out useUniqueConnection ) ;
258260 UseUniqueConnectionInstance = useUniqueConnection ;
259-
261+
260262 //UserIdentifier = !string.IsNullOrWhiteSpace(UserId) ? new UserIdentifier(UserId, UserIdentifierType.OptionalDisplayableId) : null;
261263
262264 AuthenticationType authenticationType ;
@@ -322,7 +324,7 @@ private bool GetValidUri(string uriSource, out Uri validUriResult)
322324 /// <param name="serviceUri"></param>
323325 private void SetOrgnameAndOnlineRegion ( Uri serviceUri )
324326 {
325- // uses publicaly exposed connection parser to parse
327+ // uses publicaly exposed connection parser to parse
326328 string orgRegion = string . Empty ;
327329 string orgName = string . Empty ;
328330 bool isOnPrem = false ;
@@ -334,13 +336,14 @@ private void SetOrgnameAndOnlineRegion(Uri serviceUri)
334336
335337
336338 /// <summary>
337- /// Parse the connection sting
339+ /// Parse the connection sting
338340 /// </summary>
339341 /// <param name="connectionString"></param>
342+ /// <param name="logger">Logging provider <see cref="ILogger"/></param>
340343 /// <returns></returns>
341- public static DataverseConnectionStringProcessor Parse ( string connectionString )
344+ public static DataverseConnectionStringProcessor Parse ( string connectionString , ILogger logger = null )
342345 {
343- return new DataverseConnectionStringProcessor ( connectionString . ToDictionary ( ) ) ;
346+ return new DataverseConnectionStringProcessor ( connectionString . ToDictionary ( ) , logger ) ;
344347 }
345348
346349 }
0 commit comments