Helper class used to store path made of .
| 12 | /// Helper class used to store path made of <see cref="MemberInfo"/>. |
| 13 | /// </summary> |
| 14 | [HideInEditor] |
| 15 | public struct MemberInfoPath |
| 16 | { |
| 17 | /// <summary> |
| 18 | /// The path entry. |
| 19 | /// </summary> |
| 20 | [HideInEditor] |
| 21 | public struct Entry |
| 22 | { |
| 23 | /// <summary> |
| 24 | /// The member. |
| 25 | /// </summary> |
| 26 | public readonly ScriptMemberInfo Member; |
| 27 | |
| 28 | /// <summary> |
| 29 | /// The collection index or key. |
| 30 | /// </summary> |
| 31 | public readonly object Index; |
| 32 | |
| 33 | /// <summary> |
| 34 | /// Gets the member type (field or property type). |
| 35 | /// </summary> |
| 36 | public ScriptType Type |
| 37 | { |
| 38 | get |
| 39 | { |
| 40 | var result = Member.ValueType; |
| 41 | |
| 42 | // Special case for collections |
| 43 | if (Index != null) |
| 44 | result = result.GetElementType(); |
| 45 | |
| 46 | return result; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// <summary> |
| 51 | /// Initializes a new instance of the <see cref="Entry"/> struct. |
| 52 | /// </summary> |
| 53 | /// <param name="member">The member.</param> |
| 54 | /// <param name="index">The collection index or key.</param> |
| 55 | public Entry(ScriptMemberInfo member, object index = null) |
| 56 | { |
| 57 | Member = member; |
| 58 | Index = index; |
| 59 | } |
| 60 | |
| 61 | /// <summary> |
| 62 | /// Gets the value. Handles arrays. |
| 63 | /// </summary> |
| 64 | /// <param name="instance">The instance.</param> |
| 65 | /// <returns>The result value.</returns> |
| 66 | public object GetValue(object instance) |
| 67 | { |
| 68 | object value; |
| 69 | |
| 70 | // Special case for collections |
| 71 | if (Index != null) |