public static JObject SerializeDefaults(JObject root, ISerializableView view) { if (root == null) { root = new JObject(); } if (!root.ContainsKey("type")) { root["type"] = view.ViewType; } return(root); }
public static async Task <bool> EnsureViewType(JObject root, ISerializableView view, bool throwException = true, bool showMessage = false) { var viewType = root["type"].Value <string>(); if (viewType == view.ViewType) { return(true); } if (throwException) { throw new SerializationException("Could not deserialize view - wrong view type detected."); } if (showMessage) { await XamarinHelpers.ShowOkMessage("Wrong page or view type detected", $"Expected {view.ViewType.Split('.').Last()} but found {viewType.Split('.').Last()}\n\n\n" + $"(Full types \"{view.ViewType}\" != \"{viewType}\")"); } return(false); }