diff options
author | Kangho Hur <kangho.hur@samsung.com> | 2017-10-23 13:47:06 +0900 |
---|---|---|
committer | Kangho Hur <kangho.hur@samsung.com> | 2017-10-23 13:52:29 +0900 |
commit | db4c712c0b6aa849badb9ce6d557c0019e575d01 (patch) | |
tree | a1d051c629c7210e1e0f77c23156b274931d0117 /Xamarin.Forms.Platform.Android/Deserializer.cs | |
parent | 1a7c36737dcbe6b2fc516cb72d9f3921b18c324a (diff) | |
download | xamarin-forms-db4c712c0b6aa849badb9ce6d557c0019e575d01.tar.gz xamarin-forms-db4c712c0b6aa849badb9ce6d557c0019e575d01.tar.bz2 xamarin-forms-db4c712c0b6aa849badb9ce6d557c0019e575d01.zip |
force sync with upstream 2.4.0-sr2
Change-Id: I36f0de33d03e804afd17f7ab2c60ae6f435ec402
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Deserializer.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Deserializer.cs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/Xamarin.Forms.Platform.Android/Deserializer.cs b/Xamarin.Forms.Platform.Android/Deserializer.cs index ccce9cdf..c85aaa73 100644 --- a/Xamarin.Forms.Platform.Android/Deserializer.cs +++ b/Xamarin.Forms.Platform.Android/Deserializer.cs @@ -20,28 +20,22 @@ namespace Xamarin.Forms.Platform.Android return Task.Run(() => { using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) + using (IsolatedStorageFileStream stream = store.OpenFile(PropertyStoreFile, System.IO.FileMode.OpenOrCreate)) + using (XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(stream, XmlDictionaryReaderQuotas.Max)) { - if (!store.FileExists(PropertyStoreFile)) + if (stream.Length == 0) return null; - using (IsolatedStorageFileStream stream = store.OpenFile(PropertyStoreFile, System.IO.FileMode.Open, System.IO.FileAccess.Read)) - using (XmlDictionaryReader reader = XmlDictionaryReader.CreateBinaryReader(stream, XmlDictionaryReaderQuotas.Max)) + try { - if (stream.Length == 0) - return null; - - try - { - var dcs = new DataContractSerializer(typeof(Dictionary<string, object>)); - return (IDictionary<string, object>)dcs.ReadObject(reader); - } - catch (Exception e) - { - Debug.WriteLine("Could not deserialize properties: " + e.Message); - Log.Warning("Xamarin.Forms PropertyStore", $"Exception while reading Application properties: {e}"); - } + var dcs = new DataContractSerializer(typeof(Dictionary<string, object>)); + return (IDictionary<string, object>)dcs.ReadObject(reader); + } + catch (Exception e) + { + Debug.WriteLine("Could not deserialize properties: " + e.Message); + Log.Warning("Xamarin.Forms PropertyStore", $"Exception while reading Application properties: {e}"); } - } return null; |