question

SaeedPooladzadeh-4680 avatar image
0 Votes"
SaeedPooladzadeh-4680 asked BrandoZhang-MSFT answered

need help on how to set up the configration manager for a instagram app

Hello,

Does anyone have any info on how should be the configuration manager on a C# wrapper?

For example in a wrapper like instagramApiSharp or instaSharper?

How to set up it?

thanks,

dotnet-csharpdotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

BrandoZhang-MSFT avatar image
0 Votes"
BrandoZhang-MSFT answered

Hi @SaeedPooladzadeh-4680,

I couldn't understand your requirement clearly. Do you mean you want to know a wrapper which could get asp.net core configuration(Like appsettings )?

If this is your requirement , I suggest you could consider using the IConfiguration interface inside each controller or class. The asp.net core will register the Configuration service by default.

You could directly use it inside the controller or other service class.

More details about how to use it, you could refer to below codes and this article.

 public class TestModel : PageModel
 {
     // requires using Microsoft.Extensions.Configuration;
     private readonly IConfiguration Configuration;
    
     public TestModel(IConfiguration configuration)
     {
         Configuration = configuration;
     }
    
     public ContentResult OnGet()
     {
         var myKeyValue = Configuration["MyKey"];
         var title = Configuration["Position:Title"];
         var name = Configuration["Position:Name"];
         var defaultLogLevel = Configuration["Logging:LogLevel:Default"];
    
    
         return Content($"MyKey value: {myKeyValue} \n" +
                        $"Title: {title} \n" +
                        $"Name: {name} \n" +
                        $"Default Log Level: {defaultLogLevel}");
     }
 }



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.