-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathPropertyPath.cs
111 lines (96 loc) · 2.99 KB
/
PropertyPath.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using Appercode.UI.Internals;
using Appercode.UI.Internals.PathParser;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
namespace Appercode.UI
{
[TypeConverter(typeof(PropertyPathConverter))]
public sealed class PropertyPath
{
private string path;
private List<PropertyPathStepDescriptor> descriptors;
private DependencyProperty dp;
public PropertyPath(string path, params object[] pathParameters)
{
if ((int)pathParameters.Length != 0)
{
throw new ArgumentOutOfRangeException("pathParameters");
}
this.Path = path;
}
public PropertyPath(object parameter)
{
this.dp = parameter as DependencyProperty;
if (this.dp != null)
{
this.path = "(0)";
}
}
public string Path
{
get
{
return this.path;
}
internal set
{
this.path = value;
this.dp = null;
}
}
internal IList<PropertyPathStepDescriptor> Descriptors
{
get
{
return this.descriptors;
}
}
internal bool IsPathToSource
{
get
{
return this.descriptors[0] is SourcePathStepDescriptor;
}
}
internal DependencyProperty GetDependencyProperty()
{
return this.dp;
}
internal PropertyPathListener GetListener(object source, bool listenToChanges, Appercode.UI.Data.BindingExpression exp)
{
return new PropertyPathListener(this, source, listenToChanges, exp);
}
internal bool HasDependencyProperty()
{
return this.dp != null;
}
internal void ParsePathInternal(bool calledFromParser)
{
this.descriptors = PropertyPath.ParsePath(this.path, calledFromParser);
}
private static List<PropertyPathStepDescriptor> ParsePath(string path, bool calledFromParser)
{
return (new PropertyPathParser(path, calledFromParser)).Parse();
}
}
public class PropertyPathConverter : TypeConverter
{
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
return new PropertyPath((string)value, new object[0]);
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
else
{
return base.CanConvertFrom(context, sourceType);
}
}
}
}