5 // Iain McCoy (iain@mccoy.id.au)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections;
31 namespace System.Windows {
32 public class DependencyObject {
33 private static Hashtable propertyDeclarations = new Hashtable();
34 private Hashtable properties = new Hashtable();
36 private DependencyObjectType dependencyObjectType;
37 public DependencyObjectType DependencyObjectType {
38 get { return dependencyObjectType; }
42 public void ClearValue(DependencyProperty dp)
44 throw new NotImplementedException("ClearValue(DependencyProperty dp)");
48 public void ClearValue(DependencyPropertyKey key)
50 throw new NotImplementedException("ClearValue(DependencyPropertyKey key)");
54 public LocalValueEnumerator GetLocalValueEnumerator()
56 return new LocalValueEnumerator(properties);
59 public object GetValue(DependencyProperty dp)
61 object val = properties[dp];
63 val = dp.DefaultMetadata.DefaultValue;
68 public object GetValueBase(DependencyProperty dp)
70 throw new NotImplementedException("GetValueBase(DependencyProperty dp)");
74 protected virtual object GetValueCore(DependencyProperty dp, object baseValue, PropertyMetadata metadata)
76 throw new NotImplementedException("GetValueCore(DependencyProperty dp, object baseValue, PropertyMetadata metadata)");
80 public void InvalidateProperty(DependencyProperty dp)
82 throw new NotImplementedException("InvalidateProperty(DependencyProperty dp)");
86 protected virtual void OnPropertyInvalidated(DependencyProperty dp, PropertyMetadata metadata)
88 throw new NotImplementedException("OnPropertyInvalidated(DependencyProperty dp, PropertyMetadata metadata)");
92 public object ReadLocalValue(DependencyProperty dp)
94 throw new NotImplementedException("ReadLocalValue(DependencyProperty dp)");
97 public void SetValue(DependencyProperty dp, object value)
100 ValidateValueCallback validate = dp.ValidateValueCallback;
101 if (validate != null && !validate(value))
102 throw new Exception("Value does not validate");
104 properties[dp] = value;
108 public void SetValue(DependencyPropertyKey key, object value)
110 throw new NotImplementedException("SetValue(DependencyPropertyKey key, object value)");
114 public void SetValueBase(DependencyProperty dp, object value)
116 throw new NotImplementedException("SetValueBase(DependencyProperty dp, object value)");
120 public void SetValueBase(DependencyPropertyKey key, object value)
122 throw new NotImplementedException("SetValueBase(DependencyPropertyKey key, object value)");
125 internal static DependencyProperty lookup(Type t, string name)
127 return (DependencyProperty)((Hashtable)propertyDeclarations[t])[name];
130 internal static void register(Type t, DependencyProperty dp)
132 if (propertyDeclarations[t] == null)
133 propertyDeclarations[t] = new Hashtable();
134 Hashtable typeDeclarations = (Hashtable)propertyDeclarations[t];
135 if (!typeDeclarations.ContainsKey(dp.Name))
136 typeDeclarations[dp.Name] = dp;
138 throw new Exception("A property named " + dp.Name + " already exists on " + t.Name);