/// <summary> /// Stores all perspective membership information on the current instance of an ITabularPerspectiveObject /// as annotations on the object. Perspective membership can later be retrieved using the LoadPerspectives() extension method. /// </summary> /// <param name="obj"></param> public static void SavePerspectives(this IInternalTabularPerspectiveObject obj, bool includeChildren = false) { if (obj.InPerspective.Any(ip => ip)) { obj.SetAnnotation(ANN_INPERSPECTIVE, obj.InPerspective.ToJson(), false); } if (includeChildren && obj is ITabularObjectContainer) { foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <IInternalTabularPerspectiveObject>()) { child.SavePerspectives(true); } } }
/// <summary> /// Reads any perspective membership information stored in the annotations of the current instance of an ITabularPerspectiveObject /// and applies them to the model perspectives. /// </summary> /// <param name="obj"></param> public static void LoadPerspectives(this IInternalTabularPerspectiveObject obj, bool includeChildren = false) { var p = obj.GetAnnotation(ANN_INPERSPECTIVE); if (p != null) { obj.InPerspective.CopyFrom(JsonConvert.DeserializeObject <string[]>(p)); obj.RemoveAnnotation(ANN_INPERSPECTIVE, true); } if (includeChildren && obj is ITabularObjectContainer) { foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <IInternalTabularPerspectiveObject>()) { child.LoadPerspectives(true); } } }