Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2817-BinPackingSpeedup/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/PropertySystem/Providers/ShapeProvider.cs

Last change on this file was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.2 KB
Line 
1using System;
2using System.ComponentModel;
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// Type descriptor provider for all descendants of the <see cref="ShapeBase"/> classes.
6  /// </summary>
7  class ShapeProvider : TypeDescriptionProvider {
8    #region Fields
9
10    /// <summary>
11    /// simple shape descriptor
12    /// </summary>
13    private static SimpleShapeBaseDescriptor simpleShapeBaseDescriptor;
14    /// <summary>
15    /// complex shape descriptor
16    /// </summary>
17    private static ComplexShapeBaseDescriptor complexShapeBaseDescriptor;
18
19
20    private static ClassShapeDescriptor classShapeDescriptor;
21
22    #endregion
23
24    #region Properties
25
26
27    #endregion
28
29    #region Constructor
30    public ShapeProvider() {
31      simpleShapeBaseDescriptor = new SimpleShapeBaseDescriptor(this, typeof(SimpleShapeBase));
32      complexShapeBaseDescriptor = new ComplexShapeBaseDescriptor(this, typeof(ComplexShapeBase));
33      classShapeDescriptor = new ClassShapeDescriptor(this, typeof(ClassShape));
34    }
35    #endregion
36
37    #region Methods
38    /// <summary>
39    /// Gets a custom type descriptor for the given type and object.
40    /// </summary>
41    /// <param name="objectType">The type of object for which to retrieve the type descriptor.</param>
42    /// <param name="instance">An instance of the type. Can be null if no instance was passed to the <see cref="T:System.ComponentModel.TypeDescriptor"></see>.</param>
43    /// <returns>
44    /// An <see cref="T:System.ComponentModel.ICustomTypeDescriptor"></see> that can provide metadata for the type.
45    /// </returns>
46    public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) {
47      if (typeof(SimpleShapeBase).IsInstanceOfType(instance)) {
48        return simpleShapeBaseDescriptor;
49      } else if (typeof(ClassShape).IsInstanceOfType(instance)) {
50        return classShapeDescriptor;
51      } else if (typeof(ComplexShapeBase).IsInstanceOfType(instance)) {
52        return complexShapeBaseDescriptor;
53      } else //if nothing found use the base descriptor
54        return base.GetTypeDescriptor(objectType, instance);
55
56    }
57    #endregion
58
59  }
60}
61
Note: See TracBrowser for help on using the repository browser.