本文整理汇总了C#中AppSettings类的典型用法代码示例。如果您正苦于以下问题:C# AppSettings类的具体用法?C# AppSettings怎么用?C# AppSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppSettings类属于命名空间,在下文中一共展示了AppSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
ControllerBuilder.Current.SetControllerFactory(new FunqControllerFactory(container));
var appSettings = new AppSettings();
var connString = appSettings.Get("SQLSERVER_CONNECTION_STRING",
ConfigUtils.GetConnectionString("UserAuth"));
container.Register<IDbConnectionFactory>(
new OrmLiteConnectionFactory(connString, SqlServerDialect.Provider));
//Using an in-memory cache
container.Register<ICacheClient>(new MemoryCacheClient());
ConfigureAuth(container);
var dbFactory = container.Resolve<IDbConnectionFactory>();
dbFactory.Run(d => d.CreateTableIfNotExists<UserAuth>());
dbFactory.Run(db => db.CreateTableIfNotExists<Message>());
dbFactory.Run(d => d.CreateTableIfNotExists<Device>());
SetConfig(new EndpointHostConfig
{
DefaultContentType = ContentType.Json,
EnableFeatures = Feature.All.Remove(Feature.Html).Remove(Feature.Xml),
AppendUtf8CharsetOnContentTypes = new HashSet<string> { ContentType.Json }
});
//Or if Haz Redis
//container.Register<ICacheClient>(new PooledRedisClientManager());
}
示例2: And_settings_file_does_not_exist_it_should_be_created
public void And_settings_file_does_not_exist_it_should_be_created()
{
var fileName = Guid.NewGuid() + ".config";
var fullPathToConfigurationFile = TestHelpers.GetFullPathToConfigurationFile(fileName);
try
{
Assert.IsFalse(System.IO.File.Exists(fullPathToConfigurationFile));
var settings = new AppSettings(fullPathToConfigurationFile, FileOption.None);
settings.SetValue("string", "a");
settings.SetValue<int>("int", 1);
settings.SetValue<int?>("nullableint", null);
settings.Save();
Assert.IsTrue(System.IO.File.Exists(fullPathToConfigurationFile));
Assert.IsTrue(settings.FileExists);
}
finally
{
TestHelpers.DeleteIfExists(fullPathToConfigurationFile);
}
}
示例3: WindowMain
public WindowMain()
{
InitializeComponent();
fAppSettings = new AppSettings();
fLastScanned = PageTypeEnum.Letter;
fScanner = new Scanner();
fPrinter = new Printer();
fPdfExporter = new PdfExporter();
fPdfImporter = new PdfImporter();
fImageLoader = new ImageLoader();
fImageSaver = new ImageSaver();
fDocument = new Document();
fDocument.OnPageAdded += fDocument_OnPageAdded;
fDocument.OnPageRemoved += fDocument_OnPageRemoved;
fDocument.OnPageUpdated += fDocument_OnPageUpdated;
fDocument.OnPageMoved += fDocument_OnPageMoved;
fInsertionMark = new InsertionMark();
fDragStartItem = null;
fScrollTimer = new System.Timers.Timer(150);
fScrollTimer.Elapsed += fScrollTimer_Elapsed;
fScrollTimer.AutoReset = false;
this.KeyUp += WindowMain_KeyUp;
fClosing = false;
fDeleting = false;
}
示例4: Main
public static void Main(string[] args)
{
try
{
// Open the default app.config file which in this case is SimpleExample.exe.config
// and it is located in the same folder as the SimpleExample.exe.
settings = AppSettings.CreateForAssembly(Assembly.GetEntryAssembly(), FileOption.FileMustExist);
// If you want to know the full path to the configuration file, use the FullPath property
Console.WriteLine("Full path to configuration file is: {0}", settings.FullPath);
ReadStringValues();
ReadStandardDataTypes();
ReadEnumerations();
ReadNullableValues();
ReadUsingCustomFormatProvider();
ReadOptionalValues();
ReadUsingCustomConversionFunction();
ReadConnectionString();
ReadingCustomConfigurationFile();
UpdatingValues();
CreatingAppSettings();
}
catch (Exception exp)
{
Console.Error.WriteLine(exp.Message);
throw;
}
}
示例5: FormMain
public FormMain()
{
InitializeComponent();
this.Text = AppInfo.GetApplicationName();
// Create PictureBoxPreview from special component;
this.PictureBoxPreview = new Cyotek.Windows.Forms.ImageBox();
this.PictureBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill;
this.PictureBoxPreview.TabStop = false;
this.PictureBoxPreview.BorderStyle = BorderStyle.None;
this.PictureBoxPreview.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
this.PanelPreview.Controls.Add(this.PictureBoxPreview);
fAppSettings = new AppSettings();
fScanner = new Scanner();
fPrinter = new Printer();
fPdfExporter = new PdfExporter();
fPdfImporter = new PdfImporter();
fImageLoader = new ImageLoader();
fImageSaver = new ImageSaver();
fDocument = new Document();
fDocument.OnPageAdded += fDocument_OnPageAdded;
fDocument.OnPageRemoved += fDocument_OnPageRemoved;
fDocument.OnPageUpdated += fDocument_OnPageUpdated;
fDocument.OnPageMoved += fDocument_OnPageMoved;
fClosing = false;
fDeleting = false;
MenuSettingsPrinterUsePreview.Checked = true;
}
示例6: SaveReportSettings
public void SaveReportSettings(AgrimanagrReportSettingViewModel setting)
{
var reporturl = _settingsRepository.GetByKey(SettingsKeys.ReportServerUrl);
if (reporturl == null) reporturl = new AppSettings(Guid.NewGuid());
reporturl.Key = SettingsKeys.ReportServerUrl;
reporturl.Value = setting.Server;
_settingsRepository.Save(reporturl);
var reportusername = _settingsRepository.GetByKey(SettingsKeys.ReportServerUsername);
if (reportusername == null) reportusername = new AppSettings(Guid.NewGuid());
reportusername.Key = SettingsKeys.ReportServerUsername;
reportusername.Value = setting.ReportUsername;
_settingsRepository.Save(reportusername);
var reportpassword = _settingsRepository.GetByKey(SettingsKeys.ReportServerPassword);
if (reportpassword == null) reportpassword = new AppSettings(Guid.NewGuid());
reportpassword.Key = SettingsKeys.ReportServerPassword;
reportpassword.Value = VCEncryption.EncryptString(setting.ReportPassword);
_settingsRepository.Save(reportpassword);
var reportfolder = _settingsRepository.GetByKey(SettingsKeys.ReportServerFolder);
if (reportfolder == null) reportfolder = new AppSettings(Guid.NewGuid());
reportfolder.Key = SettingsKeys.ReportServerFolder;
reportfolder.Value = setting.ReportFolder;
_settingsRepository.Save(reportfolder);
}
示例7: GetAppSettings
public AppSettings GetAppSettings()
{
var _appConfig = new AppSettings()
{
TenantAdminUrl = ConfigurationHelper.Get(TENANT_ADMIN_URL_KEY),
SPHostUrl = ConfigurationHelper.Get(SPHOSTURL_KEY),
ClientID = ConfigurationHelper.Get(CLIENTID_KEY),
ClientSecret = ConfigurationHelper.Get(CLIENTSECRET_KEY),
SupportEmailNotification = ConfigurationHelper.Get(SUPPORTTEAMNOTIFICATION_KEY),
};
////TODO ENCRYPTION
//_appConfig.TenantAdminAccount = ConfigurationHelper.Get(TENANTADMINACCOUNT_KEY);
//_appConfig.TenantAdminAccountPwd = ConfigurationHelper.Get(TENANTADMINACCOUNTPWD_KEY);
// we need to handle the boolean checks
var _autoApprove = ConfigurationHelper.Get(AUTOAPPROVESITES_KEY);
bool _result = false;
if(Boolean.TryParse(_autoApprove, out _result)) {
_appConfig.AutoApprove = _result;
}
return _appConfig;
}
示例8: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<AppSettings>(s =>
{
var appSettings = new AppSettings();
Configuration.GetSection("AppSettings").Bind(appSettings);
return appSettings;
});
services.AddSingleton<Client>(s =>
{
var appEnv = s.GetService<IApplicationEnvironment>();
var settings = s.GetService<AppSettings>();
var markdownCache = new SqliteMarkdownCache(
Path.Combine(
appEnv.ApplicationBasePath,
"releases-db.sqlite"));
return new Client(
settings.AccessToken,
markdownCache,
s.GetService<ILogger<Client>>(),
string.IsNullOrEmpty(settings.Company) ? Client.DefaultUserAgent : settings.Company
);
});
services.AddLogging();
// Add framework services.
services.AddMvc();
}
示例9: ProfileLoader
public ProfileLoader(IFileSystem fileSystem, IDirectorySystem directorySystem, IAppDirectoriesBuilder appDirBuilder, AppSettings settings)
{
_fileSystem = fileSystem;
_directorySystem = directorySystem;
_appDirBuilder = appDirBuilder;
_settings = settings;
}
示例10: ListBoxItem_Tap
private void ListBoxItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
AppSettings settings = new AppSettings();
ListBoxItem item = sender as ListBoxItem;
settings.SearchItem = (item.Content.ToString());
}
示例11: MainPage
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
_settings = new AppSettings();
UIHelper.ShowSystemTrayAsync(Color.FromArgb(255, 48, 169, 62), Colors.White);
}
示例12: SettingsPage
public SettingsPage()
{
InitializeComponent();
settings = new AppSettings();
if (settings.GPSModeSetting == GPSMode.Automatic)
{
GPSModeSwitch.IsChecked = true;
LatitudeTextBox.IsEnabled = false;
LongitudeTextBox.IsEnabled = false;
}
else
{
GPSModeSwitch.IsChecked = false;
LatitudeTextBox.IsEnabled = true;
LongitudeTextBox.IsEnabled = true;
}
LatitudeTextBox.Text = settings.GPSLatitudeSetting.ToString("0.000").Replace(",", ".");
LongitudeTextBox.Text = settings.GPSLongitudeSetting.ToString("0.000").Replace(",", ".");
if (settings.TemperatureUnitSetting == TemperatureUnit.C)
{
CelciusRadioButton.IsChecked = true;
}
else if (settings.TemperatureUnitSetting == TemperatureUnit.F)
{
FahrenheitRadioButton.IsChecked = true;
}
}
示例13: VibrateListBoxPage
public VibrateListBoxPage()
{
InitializeComponent();
mainSettings = new AppSettings();
// Vibrate Device
MainVibrateController = VibrateController.Default;
// Events
TrillVibrate.Tap += TrillVibrate_Tap;
TrillVibrateButton.Tap += TrillVibrateButton_Tap;
SpicatoVibrate.Tap += SpicatoVibrate_Tap;
SpicatoVibrateButton.Tap += SpicatoVibrateButton_Tap;
PizzicatoVibrate.Tap += PizzicatoVibrate_Tap;
PizzicatoVibrateButton.Tap += PizzicatoVibrateButton_Tap;
StaccatoVibrate.Tap += StaccatoVibrate_Tap;
StaccatoVibrateButton.Tap += StaccatoVibrateButton_Tap;
TenutoVibrate.Tap += TenutoVibrate_Tap;
TenutoVibrateButton.Tap += TenutoVibrateButton_Tap;
FermataVibrate.Tap += FermataVibrate_Tap;
FermataVibrateButton.Tap += FermataVibrateButton_Tap;
SnakeVibrate.Tap += SnakeVibrate_Tap;
SnakeVibrateButton.Tap += SnakeVibrateButton_Tap;
ZigZagVibrate.Tap += ZigZagVibrate_Tap;
ZigZagVibrateButton.Tap += ZigZagVibrateButton_Tap;
RandomVibrate.Tap += RandomVibrate_Tap;
RandomVibrateButton.Tap += RandomVibrateButton_Tap;
}
示例14: TeamReportRound
public TeamReportRound()
{
var appSettings = new AppSettings();
Name = appSettings.ReportRoundName;
StartTime = appSettings.ReportStartTime;
EndTime = appSettings.ReportEndTime;
}
示例15: GravatarProvider
public GravatarProvider(
IOptions<AppSettings> appSettings
, ApplicationUserManager userManager)
{
_appSettings = appSettings.Value;
_userManager = userManager;
}