1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Selection
6 using System.ComponentModel;
7 using System.Diagnostics;
10 // A class we use to describe what visual element is currently selected within
11 // the CategoryList class (property, category, category editor, ...)
13 internal class SelectionPath
15 private string _pathTypeId;
19 // Creates a new instance of SelectionPath with the specified
22 // <param name="pathTypeId">Token that identifies the ISelectionPathInterpreter
23 // that knows how to resolve the specified path</param>
24 // <param name="path">Path to the selected object</param>
25 public SelectionPath(string pathTypeId, string path)
27 _pathTypeId = pathTypeId;
32 // Gets the token that identifies the ISelectionPathInterpreter that knows how
33 // to resolve the contained path.
35 public string PathTypeId
36 { get { return _pathTypeId; } }
39 // Gets the path itself.
42 { get { return _path; } }
45 // Packages this instance into a serializable object
50 return new string[] { _pathTypeId, _path };
55 // Converts the serializable object returned by the State property
56 // back into an instance of SelectionPath
58 // <param name="state">State to convert</param>
59 // <returns>Instance of SelectionPath represented by the given state object</returns>
60 public static SelectionPath FromState(object state)
62 string[] values = state as string[];
63 if (values == null || values.Length != 2)
65 Debug.Fail("Invalid SelectionPath State object");
69 return new SelectionPath(values[0], values[1]);