[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / Selection / SelectionPath.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Selection 
5 {
6     using System.ComponentModel;
7     using System.Diagnostics;
8
9     // <summary>
10     // A class we use to describe what visual element is currently selected within
11     // the CategoryList class (property, category, category editor, ...)
12     // </summary>
13     internal class SelectionPath 
14     {
15         private string _pathTypeId;
16         private string _path;
17
18         // <summary>
19         // Creates a new instance of SelectionPath with the specified
20         // path ID and path.
21         // </summary>
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) 
26         {
27             _pathTypeId = pathTypeId;
28             _path = path;
29         }
30
31         // <summary>
32         // Gets the token that identifies the ISelectionPathInterpreter that knows how
33         // to resolve the contained path.
34         // </summary>
35         public string PathTypeId 
36         { get { return _pathTypeId; } }
37
38         // <summary>
39         // Gets the path itself.
40         // </summary>
41         public string Path 
42         { get { return _path; } }
43
44         // <summary>
45         // Packages this instance into a serializable object
46         // </summary>
47         public object State 
48         {
49             get {
50                 return new string[] { _pathTypeId, _path };
51             }
52         }
53
54         // <summary>
55         // Converts the serializable object returned by the State property
56         // back into an instance of SelectionPath
57         // </summary>
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) 
61         {
62             string[] values = state as string[];
63             if (values == null || values.Length != 2) 
64             {
65                 Debug.Fail("Invalid SelectionPath State object");
66                 return null;
67             }
68
69             return new SelectionPath(values[0], values[1]);
70         }
71     }
72 }