11////*********************************************************
2- // <copyright file="LocalConfigReader .cs" company="Intuit">
2+ // <copyright file="JsonFileConfigurationProvider .cs" company="Intuit">
33/*******************************************************************************
44 * Copyright 2016 Intuit
55 *
1111 *
1212 * Unless required by applicable law or agreed to in writing, software
1313 * distributed under the License is distributed on an "AS IS" BASIS,
14- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implieC:\Users\nshrivastava\Documents\Git\QuickBooks-V3-DotNET-SDK\IPPDotNetDevKitCSV3\Code\Intuit.Ipp.Core\Configuration\LocalConfigReader.csd .
14+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied .
1515 * See the License for the specific language governing permissions and
1616 * limitations under the License.
1717 *******************************************************************************/
1818//
19- // <summary>This file contains Local Config Reader.</summary>
19+ // <summary>This file contains Json file config Reader.</summary>
2020////*********************************************************
2121
2222
@@ -28,7 +28,7 @@ namespace Intuit.Ipp.Core.Configuration
2828 using System . IO ;
2929 using Intuit . Ipp . Diagnostics ;
3030 using Intuit . Ipp . Exception ;
31- //using Intuit.Ipp.Retry;
31+ //using Intuit.Ipp.Retry;
3232 using Intuit . Ipp . Security ;
3333 using Intuit . Ipp . Utility ;
3434
@@ -37,30 +37,30 @@ namespace Intuit.Ipp.Core.Configuration
3737 using Microsoft . Extensions . Configuration ;
3838#endif
3939
40-
40+
4141
4242 /// <summary>
43- /// Specifies the Default Configuration Reader implmentation used by the SDK.
43+ /// Specifies the Default Json file configuration provider implementation used by the SDK.
44+ /// By default reads "appsettings.json" file.
4445 /// </summary>
45- public class LocalConfigReader : IConfigReader
46+ public class JsonFileConfigurationProvider : Core . IConfigurationProvider
4647 {
4748
4849#if NETSTANDARD2_0
4950 public string logPath { get ; set ; }
5051 IConfigurationRoot builder ;
51- public LocalConfigReader ( string path )
52+ public JsonFileConfigurationProvider ( string path )
5253 {
5354 builder = new ConfigurationBuilder ( )
54- . SetBasePath ( Directory . GetCurrentDirectory ( ) )
55- . AddJsonFile ( path )
55+ . AddJsonFile ( path , optional : true )
5656 . Build ( ) ;
5757 //var builder = new ConfigurationBuilder()
5858 // .AddJsonFile(path)
5959 // .Build();
6060
61- //// First way
61+ //// First way
6262 //string value1 = _iconfiguration.GetSection("Data").GetSection("ConnectionString").Value;
63- //// Second way
63+ //// Second way
6464 //string value2 = _iconfiguration.GetValue<string>("Data:ConnectionString");
6565
6666
@@ -79,26 +79,26 @@ public LocalConfigReader(string path)
7979
8080
8181 }
82- public LocalConfigReader ( ) : this ( "appsettings.json" )
82+ public JsonFileConfigurationProvider ( ) : this ( "appsettings.json" )
8383 {
8484 }
8585
8686
8787#endif
8888
8989 /// <summary>
90- /// Reads the configuration from the config file and converts it to custom
90+ /// Reads the configuration from the config file and converts it to custom
9191 /// config objects which the end developer will use to get or set the properties.
9292 /// </summary>
9393 /// <returns>The custom config object.</returns>
94- public IppConfiguration ReadConfiguration ( )
94+ public IppConfiguration GetConfiguration ( )
9595 {
9696
9797
9898 IppConfiguration ippConfig = new IppConfiguration ( ) ;
9999
100100#if ! NETSTANDARD2_0
101-
101+
102102 IppConfigurationSection ippConfigurationSection = IppConfigurationSection . Instance ;
103103 if ( ippConfigurationSection == null )
104104 {
@@ -196,7 +196,7 @@ public IppConfiguration ReadConfiguration()
196196 break ;
197197 }
198198
199- //// TODO : This will not be used now.
199+ //// TODO : This will not be used now.
200200 ////if (!string.IsNullOrEmpty(ippConfigurationSection.Message.CustomSerializer.Name) && !string.IsNullOrEmpty(ippConfigurationSection.Message.CustomSerializer.Type) && ippConfigurationSection.Message.CustomSerializer.Enable)
201201 ////{
202202 //// Type customSerializerType = Type.GetType(ippConfigurationSection.Message.CustomSerializer.Type);
@@ -277,7 +277,7 @@ public IppConfiguration ReadConfiguration()
277277 break ;
278278 }
279279
280-
280+
281281 switch ( ippConfigurationSection . Retry . Mode )
282282 {
283283 case RetryMode . Linear :
@@ -336,7 +336,7 @@ public IppConfiguration ReadConfiguration()
336336
337337 ippConfig . VerifierToken = new VerifierToken ( ) ;
338338 ippConfig . VerifierToken . Value = ippConfigurationSection . WebhooksService . WebhooksVerifier . Value ;
339-
339+
340340#endif
341341#if NETSTANDARD2_0
342342
@@ -447,7 +447,7 @@ public IppConfiguration ReadConfiguration()
447447 }
448448 else if ( securityCustomSettings [ "Enable" ] == "true" )
449449 {
450- if ( ! string . IsNullOrEmpty ( securityCustomSettings [ "Name" ] ) && ! string . IsNullOrEmpty ( securityCustomSettings [ "Type" ] ) && Convert . ToBoolean ( securityCustomSettings [ "Enable" ] ) == true )
450+ if ( ! string . IsNullOrEmpty ( securityCustomSettings [ "Name" ] ) && ! string . IsNullOrEmpty ( securityCustomSettings [ "Type" ] ) )
451451 {
452452 Type customSecurityType = Type . GetType ( securityCustomSettings [ "Type" ] ) ;
453453 if ( ! string . IsNullOrEmpty ( securityCustomSettings [ "Params" ] ) )
@@ -585,7 +585,7 @@ public IppConfiguration ReadConfiguration()
585585 }
586586 }
587587 }
588-
588+
589589
590590 //ippConfig.BaseUrl = new BaseUrl();
591591
@@ -602,7 +602,7 @@ public IppConfiguration ReadConfiguration()
602602
603603 //ippConfig.VerifierToken = new VerifierToken();
604604 ippConfig . VerifierToken . Value = webhooksVerifierTokenSettings [ "Value" ] ;
605-
605+
606606#endif
607607 //#if NETSTANDARD2_0
608608 // //IppConfiguration ippConfig = new IppConfiguration();
0 commit comments