/// <summary> /// Creates whole sample structure. /// </summary> private async Task CreateAllAsync() { List <DirectoryInfo> sampleDirectories = new List <DirectoryInfo>(); var serializer = new DataContractJsonSerializer(typeof(SampleModel)); try { await Task.Run(() => { if (!File.Exists("groups.json")) { throw new NotImplementedException("groups.json file is missing"); } _sampleStructureMap = SampleStructureMap.Create("groups.json", _selectedLanguage); }); } // This is thrown if even one of the files requires permissions greater // than the application provides. catch (UnauthorizedAccessException e) { throw; //TODO } catch (DirectoryNotFoundException e) { throw; //TODO } catch (Exception e) { throw; //TODO } }
/// <summary> /// Creates whole sample structure. /// </summary> private async Task CreateAllAsync() { // You can no longer check to see if groups.json exists on disk here. You have to // open it and verify that it isn't null. Stream groupsJson = GetType().Assembly.GetManifestResourceStream("ArcGISRuntimeXamarin.groups.json"); try { await Task.Run(() => { if (groupsJson == null) { throw new NotImplementedException("groups.json file cannot be opened"); } _sampleStructureMap = SampleStructureMap.Create(groupsJson); }); } // This is thrown if even one of the files requires permissions greater // than the application provides. catch (UnauthorizedAccessException e) { throw; //TODO } catch (DirectoryNotFoundException e) { throw; //TODO } catch (Exception e) { throw; //TODO } }
public SampleStructureMap CreateSampleStructureMap(byte[] jsonInBytes) { var serializer = new DataContractJsonSerializer(typeof(SampleStructureMap)); SampleStructureMap structureMap = null; using (Stream stream = Assets.Open("groups.json")) { using (MemoryStream ms = new MemoryStream(jsonInBytes)) { structureMap = serializer.ReadObject(ms) as SampleStructureMap; structureMap.Samples = new List <SampleModel>(); } } return(structureMap); }