/// <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 ITabularPerspectiveObject obj, bool includeChildren = false)
        {
            if (obj.InPerspective.Any(ip => ip))
            {
                obj.SetAnnotation("TabularEditor_InPerspective", obj.InPerspective.ToJson(), false);
            }

            if (includeChildren && obj is ITabularObjectContainer)
            {
                foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <ITabularPerspectiveObject>())
                {
                    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 ITabularPerspectiveObject obj, bool includeChildren = false)
        {
            var p = obj.GetAnnotation("TabularEditor_InPerspective");

            if (p != null)
            {
                obj.InPerspective.CopyFrom(JsonConvert.DeserializeObject <string[]>(p));
            }

            if (includeChildren && obj is ITabularObjectContainer)
            {
                foreach (var child in (obj as ITabularObjectContainer).GetChildren().OfType <ITabularPerspectiveObject>())
                {
                    child.LoadPerspectives(true);
                }
            }
        }
示例#3
0
 internal PerspectiveIndexer(ITabularPerspectiveObject perspectiveObject) : base(perspectiveObject as TabularObject)
 {
     PerspectiveObject = perspectiveObject;
 }