当前位置: 首页>>代码示例>>C#>>正文


C# ISharedPreferences类代码示例

本文整理汇总了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));
			}
		}
开发者ID:javiersantos,项目名称:WhatsAppBetaUpdater.Xamarin,代码行数:7,代码来源:SettingsActivity.cs

示例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);
        }
开发者ID:codesharp,项目名称:cooper,代码行数:27,代码来源:CookieManager.cs

示例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);
		}
开发者ID:Redth,项目名称:Xamarin.Wear.WatchFace,代码行数:26,代码来源:SettingsFragment.cs

示例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();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:31,代码来源:Settings.cs

示例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();
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:27,代码来源:PreferencesScreen.cs

示例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);
 }
开发者ID:t-denis,项目名称:CiscoWLC.WebAuth.Client,代码行数:8,代码来源:OtherSettings.cs

示例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;
 }
开发者ID:takigava,项目名称:pikabu,代码行数:8,代码来源:MyDrawerToggle.cs

示例8: GetPref

 public static ISharedPreferences GetPref(Context context)
 {
     if (pref == null)
     {
         pref = PreferenceManager.GetDefaultSharedPreferences(context);
     }
     return pref;
 }
开发者ID:amay077,项目名称:DroidKaigi2016Xamarin,代码行数:8,代码来源:PrefUtil.cs

示例9: InfobasesScreen

        public InfobasesScreen(BaseScreen activity, ISharedPreferences prefs, InfobaseSelected resultCallback)
            : base(activity, null)
        {
            _prefs = prefs;
            _resultCallback = resultCallback;

            _manager = InfobaseManager.Current;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:8,代码来源:Infobases.cs

示例10: GetPrefs

        private ISharedPreferences GetPrefs()
        {
            if (prefs == null)
            {
                prefs = GetSharedPreferences("ACT_" + guide.Id, FileCreationMode.MultiProcess);
            }

            return prefs;
        }
开发者ID:GSDan,项目名称:Speeching_Client,代码行数:9,代码来源:GuideActivity.cs

示例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;
 }
开发者ID:sschocke,项目名称:JGCompanion,代码行数:10,代码来源:MyPreferencesFragment.cs

示例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();
		}
开发者ID:jingyul,项目名称:monodroid-samples,代码行数:25,代码来源:MainActivity.cs

示例13: OnCreate

        public override void OnCreate ()
        {
            base.OnCreate ();

            prefs = GetSharedPreferences (USER_PREFS, FileCreationMode.Private);
            userName = prefs.GetString (KEY_USERNAME, null);
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:7,代码来源:BikestoreApplication.cs

示例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;
        }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:28,代码来源:D3Calc.cs

示例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);
			};
		}
开发者ID:YourmumisEZ,项目名称:WTG,代码行数:27,代码来源:FilterActivity.cs


注:本文中的ISharedPreferences类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。