System.ComponentModel.ToolboxItemFilterAttribute.Match C# (CSharp) Method

Match() public method

public Match ( object obj ) : bool
obj object
return bool
        public override bool Match(object obj) {
        
            ToolboxItemFilterAttribute other = obj as ToolboxItemFilterAttribute;
            if (other == null) {
                return false;
            }
            
            // different filter string kills a match immediately.
            //
            if (!other.FilterString.Equals(FilterString)) {
                return false;
            }
            
            return true;
        }

Usage Example

Example #1
0
        //evaluate a filter attribute against a list, and check whther permitted
        private bool FilterPermitted(ToolboxItemFilterAttribute desFa, ICollection filterAgainst, object rootDesigner)
        {
            switch (desFa.FilterType) {
                case ToolboxItemFilterType.Allow:
                    //this is really for matching some other filter string against
                    return true;

                case ToolboxItemFilterType.Custom:
                    IToolboxUser tbUser = rootDesigner as IToolboxUser;
                    if (tbUser == null)
                        throw new ArgumentException ("Host's root designer does not support IToolboxUser interface.");
                    return EvaluateCustomFilter (tbUser);

                case ToolboxItemFilterType.Prevent:
                    //if host and toolboxitem have same filterstring, then not permitted
                    foreach (ToolboxItemFilterAttribute itemFa in filterAgainst)
                        if (desFa.Match (itemFa))
                            return false;
                    return true;

                case ToolboxItemFilterType.Require:
                    //if host and toolboxitem have same filterstring, then permitted, unless one is prevented
                    foreach (ToolboxItemFilterAttribute itemFa in filterAgainst)
                        if (desFa.Match (itemFa) && (desFa.FilterType != ToolboxItemFilterType.Prevent))
                            return true;
                    return false;
            }
            throw new InvalidOperationException ("Unexpected ToolboxItemFilterType value.");
        }
All Usage Examples Of System.ComponentModel.ToolboxItemFilterAttribute::Match