[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / PropertyEditing / categoryentry.cs
1 namespace System.Activities.Presentation.PropertyEditing {
2     using System.ComponentModel;
3     using System.Diagnostics;
4     using System.Collections.Generic;
5     using System.Collections.ObjectModel;
6     using System.Activities.Presentation;
7     using System;
8
9     /// <summary>
10     /// The CategoryEntry class is a part of the property editing object model.  It models a 
11     /// Category which has a localized name along with a collection of properties.
12     /// </summary>
13     public abstract class CategoryEntry : INotifyPropertyChanged, IPropertyFilterTarget {
14
15         private string _name;
16         private bool _matchesFilter;
17
18         /// <summary>
19         /// Creates a new CategoryEntry.  For host Infrastructure use
20         /// </summary>
21         /// <param name="name">The localized name of the corresponding Category as defined by the 
22         /// CategoryAttribute</param>
23         /// <exception cref="ArgumentNullException">When name is either empty or null.</exception>
24         protected CategoryEntry(string name) {
25             if (string.IsNullOrEmpty(name))
26                 throw FxTrace.Exception.ArgumentNull("name");
27
28             _name = name;
29         }
30
31         /// <summary>
32         /// Returns the localized Category name
33         /// </summary>
34         public string CategoryName {
35             get { return _name; }
36         }
37
38         /// <summary>
39         /// Returns an IEnumerable collection of all of the properties in the category.
40         /// </summary>
41         public abstract IEnumerable<PropertyEntry> Properties { get; }
42
43         /// <summary>
44         /// Indexer that returns a Property instance given the property name.
45         /// </summary>
46         /// <param name="propertyName">The string property name to return a Property instance for.</param>
47         /// <returns>Property corresponding to the passed in propertyName if it exists, otherwise null</returns>
48         public abstract PropertyEntry this[string propertyName] { get; }
49
50         // INotifyPropertyChanged Members
51
52         /// <summary>
53         /// INotifyPropertyChanged event
54         /// </summary>
55         public event PropertyChangedEventHandler PropertyChanged;
56
57         /// <summary>
58         /// Raises the INotifyPropertyChanged.PropertyChanged event
59         /// </summary>
60         /// <param name="propertyName">the name of the property that is changing</param>
61         /// <exception cref="ArgumentNullException">When propertyName is null</exception>
62         protected virtual void OnPropertyChanged(string propertyName) {
63             if (propertyName == null)
64                 throw FxTrace.Exception.ArgumentNull("propertyName");
65
66             if (PropertyChanged != null) {
67                 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
68             }
69         }
70
71
72         // IPropertyFilterTarget Members
73
74         /// <summary>
75         /// IPropertyFilterTarget event
76         /// </summary>
77         public event EventHandler<PropertyFilterAppliedEventArgs> FilterApplied;
78
79         /// <summary>
80         /// Raises the IPropertyFilterTarget.FilterApplied event
81         /// </summary>
82         /// <param name="filter">The PropertyFilter being applied</param>
83         protected virtual void OnFilterApplied(PropertyFilter filter) {
84             if (FilterApplied != null) {
85                 FilterApplied(this, new PropertyFilterAppliedEventArgs(filter));
86             }
87         }
88
89         /// <summary>
90         /// IPropertyFilterTarget method
91         /// </summary>
92         /// <param name="filter"></param>
93         public virtual void ApplyFilter(PropertyFilter filter) {
94             this.MatchesFilter = filter == null ? true : filter.Match(this);
95             OnFilterApplied(filter);
96         }
97         
98         /// <summary>
99         /// IPropertyFilterTarget property
100         /// </summary>
101         public virtual bool MatchesFilter {
102             get { return _matchesFilter; }
103             protected set {
104                 if (_matchesFilter != value) {
105                     _matchesFilter = value;
106                     this.OnPropertyChanged("MatchesFilter");
107                 }
108             }
109         }
110         
111         /// <summary>
112         /// IPropertyFilterTarget method
113         /// </summary>
114         /// <param name="predicate">The PropertyFilterPredicate to match against</param>
115         /// <returns>true if there is a match, otherwise false</returns>
116         public abstract bool MatchesPredicate(PropertyFilterPredicate predicate);
117
118     }
119 }
120