/// <summary> /// Load the view from from the provided JSON /// </summary> /// <param name="root">The JSON-object containing the serialized view</param> /// <param name="archive">Optional archive that the data points should be loaded from</param> /// <returns></returns> public async Task DeserializeView(JObject root, IDataStructure archive = null) { if (!await SerializableViewHelper.EnsureViewType(root, this, false, true)) { return; } var figures = XamarinHelpers.GetAllChildElements <FigureView>(PlayerContainer); foreach (var figure in figures) { figure.RemoveThisView(); } PlayerContainer.ViewerContext = ViewerContext; FigureView.DeserializationFailedWarned = false; if (root["player_container"] is JObject playerContainerJson) { await PlayerContainer.DeserializeView(playerContainerJson, archive); } if (root["playbar"] is JObject playbarJson) { await Playbar.DeserializeView(playbarJson, archive); } }
/// <summary> /// Store the important parts of the objects in the provided JSON object (or a new one if the provided one is null) /// </summary> /// <param name="root">The JSON object the view should be stored in</param> /// <returns>The serialized JSON-view</returns> public JObject SerializeView(JObject root = null) { root = SerializableViewHelper.SerializeDefaults(root, this); root["player_container"] = PlayerContainer.SerializeView(); root["playbar"] = Playbar.SerializeView(); return(root); }