@@ -55,9 +55,16 @@ private bool LoadData()
5555#else
5656 try
5757 {
58- // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
59- IsolatedStorageFileStream isoStream = null ;
60- #if ! WINDOWS_PHONE && ! WINDOWS_PHONE8
58+ // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
59+ IsolatedStorageFileStream isoStream = null ;
60+
61+ #if NET_471 && UNITY
62+ var userData = System . IO . File . ReadAllLines ( "BackendlessUserInfoUnity.txt" ) ;
63+ this . UserToken = userData [ 0 ] ;
64+ this . ObjectId = userData [ 1 ] ;
65+ return true ;
66+
67+ #elif ! WINDOWS_PHONE && ! WINDOWS_PHONE8 && ! UNITY
6168 IsolatedStorageFile isoFile =
6269 IsolatedStorageFile . GetStore ( IsolatedStorageScope . User |
6370 IsolatedStorageScope . Assembly |
@@ -111,10 +118,12 @@ private bool LoadData()
111118 return false ;
112119 }
113120#endif
114- }
121+ }
115122
116123 public void SaveData ( )
117124 {
125+ // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
126+ IsolatedStorageFileStream isoStream = null ;
118127#if UNIVERSALW8
119128 ApplicationDataContainer localSettings = ApplicationData . Current . LocalSettings ;
120129 ApplicationDataCompositeValue userInfo = new ApplicationDataCompositeValue ( ) ;
@@ -125,40 +134,43 @@ public void SaveData()
125134#else
126135 try
127136 {
128- #if ! WINDOWS_PHONE && ! WINDOWS_PHONE8
137+ #if NET_471 && UNITY
138+ System . IO . File . WriteAllLines ( "BackendlessUserInfoUnity.txt" , new string [ ] { this . UserToken , this . ObjectId } ) ;
139+ return ;
140+ #elif ! WINDOWS_PHONE && ! WINDOWS_PHONE8 && ! UNITY
129141 IsolatedStorageFile isoFile ;
130142 isoFile = IsolatedStorageFile . GetUserStoreForDomain ( ) ;
131143
132144 // Open or create a writable file.
133- IsolatedStorageFileStream isoStream =
145+ isoStream =
134146 new IsolatedStorageFileStream ( "BackendlessUserInfo" ,
135147 FileMode . OpenOrCreate ,
136148 FileAccess . Write ,
137149 isoFile ) ;
138150#else
139151 IsolatedStorageFile isoFile =
140152 IsolatedStorageFile . GetUserStoreForApplication ( ) ;
141-
142153 IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream ( "BackendlessUserInfo" ,
143154 FileMode . OpenOrCreate ,
144155 FileAccess . Write ,
145156 isoFile ) ;
146157#endif
147-
158+ #if ! UNITY
148159 StreamWriter writer = new StreamWriter ( isoStream ) ;
149160 writer . WriteLine ( this . UserToken ) ;
150161 writer . WriteLine ( this . ObjectId ) ;
151162 // StreamWriter.Close implicitly closes isoStream.
152163 writer . Close ( ) ;
153- isoFile . Dispose ( ) ;
164+ isoStream . Close ( ) ;
165+ #endif
154166 }
155167 catch ( IsolatedStorageException ex )
156168 {
157169 // Add code here to handle the exception.
158170 Console . WriteLine ( ex ) ;
159171 }
160172#endif
161- }
173+ }
162174
163175 public void DeleteFiles ( )
164176 {
@@ -168,17 +180,19 @@ public void DeleteFiles()
168180#else
169181 try
170182 {
171- #if ! WINDOWS_PHONE && ! WINDOWS_PHONE8 && ! PURE_CLIENT_LIB
183+ #if NET_471 && UNITY
184+ System . IO . File . Delete ( "BackendlessUserInfoUnity.txt" ) ;
185+ #elif ! WINDOWS_PHONE && ! WINDOWS_PHONE8 && ! PURE_CLIENT_LIB && ! UNITY
172186 IsolatedStorageFile isoFile = IsolatedStorageFile . GetStore ( IsolatedStorageScope . User |
173187 IsolatedStorageScope . Assembly |
174188 IsolatedStorageScope . Domain ,
175189 typeof ( System . Security . Policy . Url ) ,
176190 typeof ( System . Security . Policy . Url ) ) ;
177191#else
178- IsolatedStorageFile isoFile =
192+ IsolatedStorageFile isoFile =
179193 IsolatedStorageFile . GetUserStoreForDomain ( ) ;
180194#endif
181-
195+ #if ! UNITY
182196 //String[] dirNames = isoFile.GetDirectoryNames( "*" );
183197 String [ ] fileNames = isoFile . GetFileNames ( "*" ) ;
184198
@@ -195,13 +209,14 @@ public void DeleteFiles()
195209 // Confirm that no files remain.
196210 fileNames = isoFile . GetFileNames ( "*" ) ;
197211 }
212+ #endif
198213 }
199214 catch ( System . Exception e )
200215 {
201216 Console . WriteLine ( e . ToString ( ) ) ;
202217 }
203218#endif
204- }
219+ }
205220 // This method deletes directories in the specified Isolated Storage, after first
206221 // deleting the files they contain. In this example, the Archive directory is deleted.
207222 // There should be no other directories in this Isolated Storage.
0 commit comments