4894df0dae0397394b25787f5590d2e24f690a2d
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Model / AttachedPropertyDescriptor.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation.Model
6 {
7     using System;
8     using System.Collections.Generic;
9     using System.Linq;
10     using System.Text;
11     using System.ComponentModel;
12     using System.Activities.Presentation.Model;
13
14     class AttachedPropertyDescriptor : PropertyDescriptor
15     {
16         AttachedProperty AttachedProperty;
17         ModelItem owner;
18
19         public AttachedPropertyDescriptor(AttachedProperty AttachedProperty, ModelItem owner)
20             : base(AttachedProperty.Name, null)
21         {
22             this.AttachedProperty = AttachedProperty;
23             this.owner = owner;
24         }
25
26         public override AttributeCollection Attributes
27         {
28             get
29             {
30                 List<Attribute> attributeList = new List<Attribute>();
31                 foreach (Attribute attr in TypeDescriptor.GetAttributes(this.PropertyType))
32                 {
33                     attributeList.Add(attr);
34                 }
35                 BrowsableAttribute browsableAttribute = new BrowsableAttribute(this.IsBrowsable);
36                 attributeList.Add(browsableAttribute);
37                 return new AttributeCollection(attributeList.ToArray());
38             }
39         }
40
41         public override Type ComponentType
42         {
43             get { return this.owner.ItemType; }
44         }
45
46         public override bool IsReadOnly
47         {
48             get
49             {
50                 return this.AttachedProperty.IsReadOnly;
51             }
52         }
53
54         public override Type PropertyType
55         {
56             get
57             {
58                 return this.AttachedProperty.Type;
59             }
60         }
61
62         public override bool IsBrowsable
63         {
64             get
65             {
66                 return this.AttachedProperty.IsBrowsable;
67             }
68         }
69         public override bool CanResetValue(object component)
70         {
71             return false;
72         }
73
74         public override object GetValue(object component)
75         {
76
77             return this.AttachedProperty.GetValue(owner);
78         }
79
80         public override void ResetValue(object component)
81         {
82             this.AttachedProperty.ResetValue(owner);
83         }
84
85         public override void SetValue(object component, object value)
86         {
87             this.AttachedProperty.SetValue(owner, value);
88         }
89
90         public override bool ShouldSerializeValue(object component)
91         {
92             return false;
93         }
94     }
95
96 }