コード例 #1
0
        /// <summary>Constructor.</summary>
        /// <param name="storeType">The type of persistence store.</param>
        /// <param name="id">The unique identifier of the settings (used as a prefix).</param>
        protected IsolatedStorageModelBase(IsolatedStorageType storeType, string id)
        {
            // Setup initial conditions.
            if (id.AsNullWhenEmpty() == null) throw new ArgumentNullException("id");

            // Store values.
            Id = id;
            StoreType = storeType;
            Store = GetStore(storeType);

            // Set default values.
            AutoSave = true;
            AutoIncrementQuotaBy = 2;

            // Populate property values from store (if they exist).
            var propertyManager = Property;
            string serializedValues;
            if (Store.TryGetValue(id, out serializedValues))
            {
                if (!serializedValues.IsNullOrEmpty(true)) propertyManager.Populate(serializedValues);
            }

            // Wire up events.
            propertyManager.PropertySet += delegate { ProcessAutoSave(); };
        }
 public Stub(IsolatedStorageType storeType) : base(storeType, "TestId") { }
 public Stub(IsolatedStorageType storeType, string id) : base(storeType, id) { }
コード例 #4
0
        // Use the return value from this method within a 'Using' statement to release resources when done.
        private static IsolatedStorageFile GetStoreFile(IsolatedStorageType storeType)
        {
            switch (storeType)
            {
                case IsolatedStorageType.Application: return IsolatedStorageFile.GetUserStoreForApplication();
                case IsolatedStorageType.Site: return IsolatedStorageFile.GetUserStoreForSite();

                default: throw new NotSupportedException(storeType.ToString());
            }
        }
コード例 #5
0
 private static IsolatedStorageSettings GetStore(IsolatedStorageType storeType)
 {
     switch (storeType)
     {
         case IsolatedStorageType.Application: return IsolatedStorageSettings.ApplicationSettings;
         case IsolatedStorageType.Site: return IsolatedStorageSettings.SiteSettings;
         
         default: throw new NotSupportedException(storeType.ToString());
     }
 }