本文整理汇总了C#中ISharedPreferences类的典型用法代码示例。如果您正苦于以下问题:C# ISharedPreferences类的具体用法?C# ISharedPreferences怎么用?C# ISharedPreferences使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISharedPreferences类属于命名空间,在下文中一共展示了ISharedPreferences类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key) {
Preference pref = FindPreference (key);
if (pref == prefHoursNotifications) {
prefHoursNotifications.Summary = string.Format (Resources.GetString (Resource.String.settings_interval_description), Resources.GetStringArray(Resource.Array.hours).GetValue(int.Parse(prefs.GetString ("prefHoursNotifications", "4"))-1));
}
}
示例2: SaveCookie
public static void SaveCookie(ISharedPreferences sharedPreferences, string cookieKey, Cookie cookie)
{
var editor = sharedPreferences.Edit();
var cookieValueItems = new List<string>();
var itemFormat = "{0}:{1}";
cookieValueItems.Clear();
cookieValueItems.Add(string.Format(itemFormat, "Domain", cookie.Domain));
cookieValueItems.Add(string.Format(itemFormat, "Name", cookie.Name));
cookieValueItems.Add(string.Format(itemFormat, "Value", cookie.Value));
cookieValueItems.Add(string.Format(itemFormat, "Expires", cookie.Expires.ToString()));
cookieValueItems.Add(string.Format(itemFormat, "Comment", cookie.Comment));
cookieValueItems.Add(string.Format(itemFormat, "CommentUri", cookie.CommentUri != null ? cookie.CommentUri.AbsoluteUri : null));
cookieValueItems.Add(string.Format(itemFormat, "Discard", cookie.Discard));
cookieValueItems.Add(string.Format(itemFormat, "HttpOnly", cookie.HttpOnly));
cookieValueItems.Add(string.Format(itemFormat, "Path", cookie.Path));
cookieValueItems.Add(string.Format(itemFormat, "Port", cookie.Port));
cookieValueItems.Add(string.Format(itemFormat, "Secure", cookie.Secure));
cookieValueItems.Add(string.Format(itemFormat, "Version", cookie.Version));
editor.PutString(cookieKey, string.Join("|", cookieValueItems.ToArray()));
editor.Commit();
var logger = DependencyResolver.Resolve<ILoggerFactory>().Create(typeof(CookieManager));
logger.InfoFormat("Saved Cookie. Domain:{0}, Name:{1}, Value:{2}, Expires:{3}", cookie.Domain, cookie.Name, cookie.Value, cookie.Expires);
}
示例3: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged (ISharedPreferences sharedPreferences, string key)
{
Console.WriteLine ("Preference Changed: " + key);
switch (key) {
case "prefshowxamarin":
settings.ShowXamarinLogo = sharedPreferences.GetBoolean (key, true);
break;
case "pref24hourclock":
settings.Use24Clock = sharedPreferences.GetBoolean (key, false);
break;
case "prefshowdayofweek":
settings.ShowDayOfWeek = sharedPreferences.GetBoolean (key, true);
break;
case "prefshowdate":
settings.ShowDate = sharedPreferences.GetBoolean (key, true);
break;
}
settings.Save ();
Console.WriteLine ("Settings> " + settings);
var evt = OnSettingsChanged;
if (evt != null)
evt (settings);
}
示例4: Settings
public Settings(ISharedPreferences preferences, string systemLanguage, InfobaseManager.Infobase infobase)
{
_preferences = preferences;
Language = systemLanguage;
_name = infobase.Name;
BaseUrl = infobase.BaseUrl;
ApplicationString = infobase.ApplicationString;
FtpPort = infobase.FtpPort;
string lastUrl = _preferences.GetString("url", string.Empty);
if (BaseUrl == lastUrl)
{
UserName = _preferences.GetString("user", infobase.UserName);
Password = _preferences.GetString("password", infobase.Password);
}
else
{
UserName = infobase.UserName;
Password = infobase.Password;
}
ClearCacheOnStart = infobase.IsActive && _preferences.GetBoolean("clearCache", ForceClearCache);
infobase.IsActive = true;
infobase.IsAutorun = true;
WriteSettings();
}
示例5: OnSharedPreferenceChanged
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
{
if (key != "clearCache" && key != "anonymousAccess")
{
string value = sharedPreferences.GetString(key, string.Empty);
FillSummary(key, value);
if ((key == "user" || key == "password" || key == "url") && !sharedPreferences.GetBoolean("clearCache", true))
{
ISharedPreferencesEditor editor = sharedPreferences.Edit();
editor.PutBoolean("clearCache", true);
editor.Commit();
MakeToast(D.NEED_TO_REBOOT_FULL);
}
if (key == "application")
MakeToast(D.NEED_TO_REBOOT);
}
else
{
MakeToast(D.NEED_TO_REBOOT_FULL);
}
BitBrowserApp.Current.SyncSettings();
}
示例6: OtherSettings
internal OtherSettings(ISharedPreferences sharedPrefs)
{
ConnectTimeout = int.Parse(sharedPrefs.GetString("pref_timeout_connect", "10000"));
ConnectCheckInterval = int.Parse(sharedPrefs.GetString("pref_interval_check_connect", "200"));
ToastLevel = (ToastLevel)int.Parse(sharedPrefs.GetString("pref_toasts_level", "2"));
IgnoreSslCertErrors = sharedPrefs.GetBoolean("pref_ignore_ssl_errors", true);
StartUrl = sharedPrefs.GetString("pref_start_url", null);
}
示例7: MyDrawerToggle
public MyDrawerToggle(AppCompatActivity host, DrawerLayout drawerLayout, int openedResource, int closedResource,ISharedPreferences pref)
: base(host, drawerLayout, openedResource, closedResource)
{
_mHostActivity = host;
_mOpenedResource = openedResource;
_mClosedResource = closedResource;
_pref = pref;
}
示例8: GetPref
public static ISharedPreferences GetPref(Context context)
{
if (pref == null)
{
pref = PreferenceManager.GetDefaultSharedPreferences(context);
}
return pref;
}
示例9: InfobasesScreen
public InfobasesScreen(BaseScreen activity, ISharedPreferences prefs, InfobaseSelected resultCallback)
: base(activity, null)
{
_prefs = prefs;
_resultCallback = resultCallback;
_manager = InfobaseManager.Current;
}
示例10: GetPrefs
private ISharedPreferences GetPrefs()
{
if (prefs == null)
{
prefs = GetSharedPreferences("ACT_" + guide.Id, FileCreationMode.MultiProcess);
}
return prefs;
}
示例11: DisplayCurrentPreferenceValues
void DisplayCurrentPreferenceValues(ISharedPreferences sharedPreferences)
{
Preference pilotName = FindPreference("pref_pilotname");
string curPilotName = sharedPreferences.GetString("pref_pilotname", "");
if (curPilotName == "")
{
curPilotName = "Enter your pilot name";
}
pilotName.Summary = curPilotName;
}
示例12: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView(Resource.Layout.main_activity);
mAddGeofencesButton = FindViewById<Button>(Resource.Id.add_geofences_button);
mRemoveGeofencesButton = FindViewById<Button>(Resource.Id.remove_geofences_button);
mAddGeofencesButton.Click += AddGeofencesButtonHandler;
mRemoveGeofencesButton.Click += RemoveGeofencesButtonHandler;
mGeofenceList = new List<IGeofence>();
mGeofencePendingIntent = null;
mSharedPreferences = GetSharedPreferences(Constants.SHARED_PREFERENCES_NAME,
FileCreationMode.Private);
mGeofencesAdded = mSharedPreferences.GetBoolean(Constants.GEOFENCES_ADDED_KEY, false);
SetButtonsEnabledState();
PopulateGeofenceList();
BuildGoogleApiClient();
}
示例13: OnCreate
public override void OnCreate ()
{
base.OnCreate ();
prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private);
userName = prefs.GetString (KEY_USERNAME, null);
}
示例14: OnCreate
public override void OnCreate()
{
base.OnCreate();
Instance = this;
// Load preferences
Preferences = GetSharedPreferences(SettingsFilename, FileCreationMode.Private);
// Default offline mode
D3Context.Instance.FetchMode = (Preferences.GetBoolean(SettingsOnlinemode, false) ? FetchMode.Online : FetchMode.OnlineIfMissing);
// Checks if some migration operations are needed
var upToDateVersion = Preferences.GetInt(UpToDateVersion, 1);
if (upToDateVersion < 20)
{
new MigrationTo20().DoMigration();
}
// Always start D3Api with cache available
var dataProvider = new CacheableDataProvider(new HttpRequestDataProvider())
{
FetchMode = D3Context.Instance.FetchMode
};
D3Api.DataProvider = dataProvider;
// Set english locale by default
D3Api.Locale = CultureInfo.CurrentCulture.TwoLetterISOLanguageName;
}
示例15: OnCreate
protected override void OnCreate (Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
SetContentView(Resource.Layout.Filter);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
RadioButton radio_gps = FindViewById<RadioButton>(Resource.Id.radioButton1);
RadioButton radio_fb = FindViewById<RadioButton>(Resource.Id.radioButton2);
prefs = PreferenceManager.GetDefaultSharedPreferences(this);
string localizationSetting = prefs.GetString("localization","");
if (localizationSetting == "facebook") {
radio_fb.Checked = true;
radio_gps.Checked = false;
}
else
{
radio_fb.Checked = false;
radio_gps.Checked = true;
}
radio_gps.Click += RadioButtonClick;
radio_fb.Click += RadioButtonClick;
Button backButton = FindViewById<Button>(Resource.Id.button1);
backButton.Click += (object sender, EventArgs e) => {
Intent intent = new Intent (this, typeof(MainActivity));
StartActivityForResult (intent, 0);
};
}