本文整理汇总了C#中Setting.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Setting.ToString方法的具体用法?C# Setting.ToString怎么用?C# Setting.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting.ToString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set
public static void Set(Setting setting, string value)
{
var settingName = setting.ToString();
var bytes = Encoding.UTF8.GetBytes(value);
var encryptedBytes = ProtectedData.Protect(bytes, null);
IsolatedStorageSettings.ApplicationSettings[settingName] = encryptedBytes;
}
示例2: GetString
public static string GetString(Setting setting)
{
var settingName = setting.ToString();
if (IsolatedStorageSettings.ApplicationSettings.Contains(settingName))
{
var encryptedBytes = (byte[])IsolatedStorageSettings.ApplicationSettings[settingName];
var bytes = ProtectedData.Unprotect(encryptedBytes, null);
return Encoding.UTF8.GetString(bytes, 0, bytes.Length);
}
else
{
return "";
}
}
示例3: GetSettingName
public static string GetSettingName(Setting settingNameEnum)
{
if (SettingNames._cache.Count() == 0)
{
LoadDictionary(SettingNames, "setting.names.json");
}
return SettingNames.GetString(settingNameEnum.ToString());
}
示例4: DB_UpdateSetting
/// <summary>
/// Updates a program setting
/// </summary>
/// <param name="DBSetting">The setting to update</param>
/// <param name="value">The new value for the setting</param>
internal static int DB_UpdateSetting(Setting DBSetting, object value)
{
//setup parameters
SQLiteParameter sqParam = null;
switch (DBSetting) {
case Setting.BackgroundColour:
case Setting.DBversion:
case Setting.member_id:
case Setting.NewUser:
case Setting.ReadInterval:
case Setting.RowColourAlt:
case Setting.RowColourHighlight:
case Setting.SendReports:
case Setting.ShowDate:
case Setting.ShowGrid:
int iConvertedValue;
if (int.TryParse(value.ToString().Trim(), out iConvertedValue)) {
sqParam = new SQLiteParameter("@value", DbType.Int32) {
Value = iConvertedValue
};
}
break;
case Setting.FormPosition:
case Setting.GallerySettings:
case Setting.ImageBrowser:
case Setting.Notes:
case Setting.pass_hash:
case Setting.RootPath:
case Setting.SavePath:
case Setting.SearchIgnore:
sqParam = new SQLiteParameter("@value", DbType.String) {
Value = value.ToString()
};
break;
}
//determine whether to insert or update
string sCommandText = string.Format(
"update [Settings] set {0} = @value"
, DBSetting.ToString());
//run the command
return sqlBase.ExecuteNonQuery(sCommandText, CommandBehavior.Default, sqParam);
}
示例5: GetSetting
/// <summary>
/// Returns a setting from the DB
/// </summary>
/// <param name="DBSetting"></param>
public static string GetSetting(Setting DBSetting)
{
string sVal = "";
using (DataTable dt = SQLAccess.DB_GetSettings()) {
sVal = dt.Rows[0][DBSetting.ToString()].ToString();
}
return sVal;
}
示例6: TrySetIndividualSetting
private void TrySetIndividualSetting(IsolatedStorageSettings settings, Setting settingNameEnum, string settingValue)
{
var settingName = settingNameEnum.ToString();
if (settings.Contains(settingName))
{
settings[settingName] = settingValue;
}
else
{
settings.Add(settingName, settingValue);
}
}
示例7: SetValue
/// <summary>
/// Internal method to set the value of a specified setting in the in-memory settings file.
/// If the specified setting does not exist then it is added.
/// </summary>
/// <param name="node">The setting to set the value of</param>
/// <param name="value">The value to assign to the specified setting</param>
private void SetValue(Setting node, string value)
{
XmlNode xmlNode = _xml.SelectSingleNode("/CharacterSettings/" + node.ToString());
try
{
if (xmlNode == null)
{
XmlNode parent = _xml.SelectSingleNode("/CharacterSettings");
xmlNode = _xml.CreateElement(node.ToString());
parent.AppendChild(xmlNode);
}
if (xmlNode.FirstChild == null)
{
XmlText xmlValue = _xml.CreateTextNode(value);
xmlNode.AppendChild(xmlValue);
}
else
{
xmlNode.FirstChild.Value = value;
}
_changed = true;
if (SettingsUpdated != null)
{
SettingsUpdated(this, null);
}
}
catch (Exception ex)
{
EMMASettingsException emmaEx = new EMMASettingsException(ExceptionSeverity.Error,
"Error setting value in character settings file for " + node.ToString(), ex);
}
}
示例8: GetValueNode
/// <summary>
///
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private XmlNode GetValueNode(Setting node)
{
XmlNode xmlNode = _xml.SelectSingleNode("/CharacterSettings/" + node.ToString());
try
{
if (xmlNode == null)
{
XmlNode parent = _xml.SelectSingleNode("/CharacterSettings");
xmlNode = _xml.CreateElement(node.ToString());
parent.AppendChild(xmlNode);
}
if (xmlNode.FirstChild == null)
{
XmlText xmlValue = _xml.CreateTextNode(GetDefaultValue(node));
xmlNode.AppendChild(xmlValue);
}
}
catch (Exception ex)
{
EMMASettingsException emmaEx = new EMMASettingsException(ExceptionSeverity.Error,
"Error getting value from character settings file for " + node.ToString(), ex);
}
return xmlNode;
}
示例9: GetSetting
/// <summary>
/// Returns a setting from the DB
/// </summary>
/// <param name="DBSetting"></param>
public static string GetSetting(Setting DBSetting)
{
string sVal = "";
using (DataTable dt = SQLAccess._GetSettings()) {
if (dt.Rows.Count > 0) {
sVal = dt.Rows[0][DBSetting.ToString()].ToString().Trim();
}
}
return sVal;
}
示例10: _UpdateSetting
/// <summary>
/// Updates a program setting
/// </summary>
/// <param name="DBSetting">The setting to update</param>
/// <param name="value">The new value for the setting</param>
internal static int _UpdateSetting(Setting DBSetting, object value)
{
//setup parameters
SQLiteParameter sqParam = null;
switch (DBSetting) {
case Setting.BackgroundColour:
case Setting.RowColourAlt:
case Setting.RowColourHighlight:
if (value is Color) {
sqParam = SQLBase.NewParameter("@value", DbType.Int32, ((Color)value).ToArgb());
}
break;
case Setting.NewUser:
case Setting.IsAdmin:
case Setting.ShowDate:
case Setting.ShowGrid:
case Setting.ShowCovers:
case Setting.RemoveTitleAddenda:
if (value is bool) {
sqParam = SQLBase.NewParameter("@value", DbType.Int32, (bool)value ? 1 : 0);
}
break;
case Setting.SendReports:
case Setting.DBversion:
case Setting.member_id:
case Setting.ReadInterval:
int iConvertedValue;
if (int.TryParse(value.ToString().Trim(), out iConvertedValue)) {
sqParam = SQLBase.NewParameter("@value", DbType.Int32, iConvertedValue);
}
break;
case Setting.FormPosition:
if (value is Rectangle) {
Rectangle rct = (Rectangle)value;
string svalue = string.Format("{0},{1},{2},{3}"
, rct.Location.X > -1 ? rct.Location.X : 0
, rct.Location.Y > -1 ? rct.Location.Y : 0
, rct.Size.Width
, rct.Size.Height);
sqParam = SQLBase.NewParameter("@value", DbType.String, svalue);
}
break;
case Setting.ImageBrowser:
case Setting.Notes:
case Setting.pass_hash:
case Setting.RootPath:
case Setting.SavePath:
sqParam = SQLBase.NewParameter("@value", DbType.String, value.ToString());
break;
case Setting.GallerySettings:
if (value is byte[]) {
sqParam = SQLBase.NewParameter("@value", DbType.String, string.Join(",", (byte[])value));
}
break;
case Setting.SearchIgnore:
case Setting.TagIgnore:
if (value is string[]) {
sqParam = SQLBase.NewParameter("@value", DbType.String, string.Join("|", (string[])value));
}
break;
}
int iAltered = -1;
if (sqParam != null) {
string sCommandText = string.Format("update [Settings] set {0} = @value", DBSetting.ToString());
iAltered = sqlBase.ExecuteNonQuery(sCommandText, sqParam);
}
else {
SQL.LogMessage("Setting was not a valid datatype", EventType.CustomException, value);
xMessage.ShowError("Invalid settings data was ignored.");
}
return iAltered;
}
示例11: SetValue
/// <summary>
/// Internal method to set the value of a specified setting in the in-memory settings file.
/// If the specified setting does not exist then it is added.
/// </summary>
/// <param name="node">The setting to set the value of</param>
/// <param name="value">The value to assign to the specified setting</param>
private void SetValue(Setting node, string value)
{
SetValue(node.ToString(), value);
}
示例12: GetValue
/// <summary>
/// Internal method to return the value of a specified setting from the in-memory settings file.
/// If the value does not exist then it is added from the default values returned by GetDefaultValue.
/// </summary>
/// <param name="node">The setting to return the value for</param>
/// <returns></returns>
private string GetValue(Setting node)
{
return GetValue(node.ToString());
}
示例13: GetSetting
public Object GetSetting(Setting setting)
{
return GetSetting(setting.ToString());
}
示例14: SetSetting
public Boolean SetSetting(Setting setting, Object value)
{
return SetSetting(setting.ToString(), value);
}