public async Task <string> GetExportLibraryContentAsync() { var exportObject = new ImportExportObject { Books = await App.BookRepository.Get(), Movies = await App.MoviesRepository.Get() }; return(JsonConvert.SerializeObject(exportObject, Formatting.Indented)); }
public async Task <int> ImportBooksAsync(byte[] dataArray) { string contents = System.Text.Encoding.UTF8.GetString(dataArray); ImportExportObject importObject = JsonConvert.DeserializeObject <ImportExportObject>(contents); foreach (var book in importObject.Books) { await App.BookRepository.Insert(book); } foreach (var movie in importObject.Movies) { await App.MoviesRepository.Insert(movie); } MessagingCenter.Send(this, "Addbooks", importObject.Books); return(importObject.Books.Count); }
public override void OnInspectorGUI() { ImportExportObject editorTarget = target as ImportExportObject; if (GUILayout.Button(editorTarget.ImportButtonText)) { editorTarget.Import(); Debug.Log(editorTarget.ImportMessage); } EditorGUILayout.HelpBox(editorTarget.HelpBoxImport, MessageType.Info); EditorGUILayout.Space(); if (GUILayout.Button(editorTarget.ExportButtonText)) { editorTarget.Export(); Debug.Log(editorTarget.ExportMessage); } EditorGUILayout.HelpBox(editorTarget.HelpBoxExport, MessageType.Info); EditorGUILayout.Space(); base.OnInspectorGUI(); }