Fix IsolatedStorageFile.GetUserStoreForApplication() for MOBILE.
authorJonathan Pryor <jonpryor@vt.edu>
Tue, 12 Oct 2010 02:26:38 +0000 (22:26 -0400)
committerJonathan Pryor <jonpryor@vt.edu>
Tue, 12 Oct 2010 02:30:50 +0000 (22:30 -0400)
IsolatedStorageFile.GetUserStoreForApplication() would previously throw an
IsolatedStorageException because no ApplicationIdentity was provided by the
AppDomain.

We would like to provide this method in a workable fashion to facilitate code
portability with Windows Phone 7, which exposes only this method for saving
files to stable storage.

Thus, skip the ApplicationIdentity and code identity checks for MOBILE
(MonoDroid, MonoTouch) so that IsolatedStorage Just Works.

mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs
mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorageFile.cs

index 12cfc1b4db60c7c2c9e651bcd5c8ca292d28f803..95728851d5876ac8318e5ebc361256373b199b9e 100644 (file)
@@ -169,12 +169,14 @@ namespace System.IO.IsolatedStorage {
                [MonoTODO ("requires manifest support")]
                protected void InitStore (IsolatedStorageScope scope, Type appEvidenceType)
                {
+#if !MOBILE
                        if (AppDomain.CurrentDomain.ApplicationIdentity == null)
                                throw new IsolatedStorageException (Locale.GetText ("No ApplicationIdentity available for AppDomain."));
 
                        if (appEvidenceType == null) {
                                // TODO - Choose evidence
                        }
+#endif
 
                        // no exception here because this can work without CAS
                        storage_scope = scope;
index a23bba4d8f1c5d7b6db7600a7f2e2376a44c0c6b..306f970d7d2b7c2e2d0ea93c9e1b1fa15458f6b3 100644 (file)
@@ -385,6 +385,9 @@ namespace System.IO.IsolatedStorage {
                {
                        string root = GetIsolatedStorageRoot (Scope);
                        string dir = null;
+#if MOBILE
+                       dir = "";
+#else
                        if (_applicationIdentity != null) {
                                dir = String.Format ("a{0}{1}", SeparatorInternal, GetNameFromIdentity (_applicationIdentity));
                        } else if (_domainIdentity != null) {
@@ -395,6 +398,7 @@ namespace System.IO.IsolatedStorage {
                        } else {
                                throw new IsolatedStorageException (Locale.GetText ("No code identity available."));
                        }
+#endif
 
                        root = Path.Combine (root, dir);