appsettings

AppSettings.json for Integration Test in ASP.NET Core

北慕城南 提交于 2019-11-27 03:49:22
问题 I am following this guide. I have a Startup in the API project that uses an appsettings.json configuration file. public class Startup { public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .ReadFrom.Configuration(Configuration)

How can I read/write app.config settings at runtime without using user settings?

大憨熊 提交于 2019-11-27 03:40:45
I'm looking for a way to store application or machine level settings that can be written to at runtime using Application Settings . User settings allow read/write but application settings do not. I have been using user settings for saving settings like this at runtime but this has really proven to be impractical for the following reasons: All users of the machine need to share settings. In support calls (especially in crisis situations) it is difficult to explain to users/employees where to find and modify these settings manually (appdata is a hidden folder among other things). New versions of

Restoring Window Size/Position With Multiple Monitors

限于喜欢 提交于 2019-11-27 02:58:33
Many posts around about restoring a WinForm position and size. Examples: www.stackoverflow.com/questions/92540/save-and-restore-form-position-and-size www.codeproject.com/KB/dialog/restoreposition.aspx?fid=1249382&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2595746 But I have yet to find code to do this with multiple monitors. That is, if I close my .NET Winform app with the window on monitor 2, I want it to save the windows size, location, and state to the application settings, so it could later restore to monitor 2 when I restart the app. It would be nice if, like in the codeproject

Change Azure website app settings from code

扶醉桌前 提交于 2019-11-26 23:05:43
Is it possible to change the app settings for a website from the app itself? This is not meant to be an everyday operation, but a self-service reconfiguration option. A non-developer can change a specific setting, which should cause a restart, just like I can do manually on the website configuration page (app setting section) It wasn't that hard once I found the right lib to do it, Microsoft Azure Web Sites Management Library . var credentials = GetCredentials(/*using certificate*/); using (var client = new WebSiteManagementClient(credentials)) { var currentConfig = await client.WebSites

Get ConnectionString from appsettings.json instead of being hardcoded in .NET Core 2.0 App

我只是一个虾纸丫 提交于 2019-11-26 19:27:40
问题 I have the following class in NET Core2.0 App. // required when local database does not exist or was deleted public class ToDoContextFactory : IDesignTimeDbContextFactory<AppContext> { public AppContext CreateDbContext(string[] args) { var builder = new DbContextOptionsBuilder<AppContext>(); builder.UseSqlServer("Server=localhost;Database=DbName;Trusted_Connection=True;MultipleActiveResultSets=true"); return new AppContext(builder.Options); } } This is required in Core 2.0 with migration when

Find current country from iPhone device

旧城冷巷雨未停 提交于 2019-11-26 18:53:33
问题 I have to get the current country in the iPhone settings. Can anyone tell me how to get the current country in iPhone application. I have to use the current country for parsing the RSS feed in which I need to pass the current country. Please help me out to find the country . Thanks in advance. 回答1: To find the country of the user's chosen language: NSLocale *currentLocale = [NSLocale currentLocale]; // get the current locale. NSString *countryCode = [currentLocale objectForKey

appSettings vs applicationSettings. appSettings outdated? [duplicate]

亡梦爱人 提交于 2019-11-26 18:01:03
问题 This question already has an answer here: Pros and cons of AppSettings vs applicationSettings (.NET app.config / Web.config) 5 answers I've got some questions about two ways to save settings in the web.config. Appsettings : Look in web.config <appSettings> <add key="key1" value="value1"/> <add key="key2" value="value2"/> </appSettings> Usage in code-behind : ConfigurationManager.AppSettings["key1"]; ApplicationSettings/ Properties (autogenerated by using the 'properties'-tab in the project)

Objective-C - Detect when user change the app&#39;s notifications settings

我只是一个虾纸丫 提交于 2019-11-26 12:45:04
问题 I need to always know which options the user choose on the push notification settings. (The options are - alert, sound and badges) So when my app launch I call: UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; and detect what the user chose. But how can I detect if the user change the settings later during the app life time? Is there some delegate method that get called when a change occur with this settings? 回答1: There is no delegate. You

Why isn&#39;t there an XML-serializable dictionary in .NET?

巧了我就是萌 提交于 2019-11-26 11:43:22
I need an XML-serializable dictionary. Actually, I now have two quite different programs that need one. I was rather surprised to see that .NET doesn't have one. I asked the question elsewhere and got sarcastic responses. I don't understand why it's a stupid question. Can someone enlighten me, given how dependent various .NET features are on XML serialization, why there isn't an XML-serializable dictionary. Hopefully, you can also explain why some people consider that a daft question. I guess I must be missing something fundamental and I'm hoping you'll be able to fill in the gaps. The thing

Reading settings from app.config or web.config in .net

依然范特西╮ 提交于 2019-11-26 11:28:27
I'm working on a C# class library that needs to be able to read settings from the web.config or app.config file (depending on whether the DLL is referenced from an ASP.NET web application or a Windows Forms application). I've found that ConfigurationSettings.AppSettings.Get("MySetting") works, but that code has been marked as deprecated by Microsoft. I've read that I should be using: ConfigurationManager.AppSettings["MySetting"] However, the System.Configuration.ConfigurationManager class doesn't seem to be available from a C# Class Library project. Does anyone know what the best way to do