2010-06-03 Jb Evain <jbevain@novell.com>
[mcs.git] / class / WindowsBase / System.Windows / DependencyObjectType.cs
blobe8280d4f9fb237e6432ed88d0839120ee046d4c0
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // (C) 2005 Iain McCoy
21 // (C) 2007 Novell, Inc.
23 // Authors:
24 // Iain McCoy (iain@mccoy.id.au)
25 // Chris Toshok (toshok@ximian.com)
29 using System.Collections.Generic;
31 namespace System.Windows {
32 public class DependencyObjectType {
34 private static Dictionary<Type,DependencyObjectType> typeMap = new Dictionary<Type,DependencyObjectType>();
35 private static int current_id;
37 private int id;
38 private Type systemType;
40 private DependencyObjectType (int id, Type systemType)
42 this.id = id;
43 this.systemType = systemType;
46 public DependencyObjectType BaseType {
47 get { return DependencyObjectType.FromSystemType (systemType.BaseType); }
50 public int Id {
51 get { return id; }
54 public string Name {
55 get { return systemType.Name; }
58 public Type SystemType {
59 get { return systemType; }
62 public static DependencyObjectType FromSystemType(Type systemType)
64 if (typeMap.ContainsKey (systemType))
65 return typeMap[systemType];
67 DependencyObjectType dot;
69 typeMap[systemType] = dot = new DependencyObjectType (current_id++, systemType);
71 return dot;
74 public bool IsInstanceOfType(DependencyObject d)
76 return systemType.IsInstanceOfType (d);
79 public bool IsSubclassOf(DependencyObjectType dependencyObjectType)
81 return systemType.IsSubclassOf (dependencyObjectType.SystemType);
84 public override int GetHashCode ()
86 throw new NotImplementedException ();