public void Ctor_String(string filterString) { var attribute = new ToolboxItemFilterAttribute(filterString); Assert.Equal(filterString ?? string.Empty, attribute.FilterString); Assert.Equal(ToolboxItemFilterType.Allow, attribute.FilterType); }
public void TypeId_ValidEditorBaseTypeName_ReturnsExcepted(string filterType, object expected) { var attribute = new ToolboxItemFilterAttribute(filterType); Assert.Equal(expected, attribute.TypeId); Assert.Same(attribute.TypeId, attribute.TypeId); }
public void Ctor_String_ToolboxItemFilterType(string filterString, ToolboxItemFilterType filterType) { var attribute = new ToolboxItemFilterAttribute(filterString, filterType); Assert.Equal(filterString ?? string.Empty, attribute.FilterString); Assert.Equal(filterType, attribute.FilterType); }
public virtual void AddToToolbox([NotNull] ProjectItem projectItem) { Assert.ArgumentNotNull(projectItem, nameof(projectItem)); var toolboxService = SitecorePackage.Instance.GetService <IToolboxService>(); if (toolboxService == null) { return; } var newFilter = new ToolboxItemFilterAttribute("System.Web.UI", ToolboxItemFilterType.Allow); var toolboxItem = new ToolboxItem { Bitmap = new Bitmap(16, 16), Description = projectItem.Path, DisplayName = Path.GetFileNameWithoutExtension(projectItem.Path), IsTransient = true, Filter = new[] { newFilter } }; toolboxService.AddToolboxItem(toolboxItem, "Sitecore"); }
private static ICollection MergeFilter(ToolboxItem item) { ICollection filter = item.Filter; ArrayList list = new ArrayList(); foreach (Attribute attribute in TypeDescriptor.GetAttributes(item)) { if (attribute is ToolboxItemFilterAttribute) { list.Add(attribute); } } if ((filter == null) || (filter.Count == 0)) { return(list); } if (list.Count > 0) { Hashtable hashtable = new Hashtable(list.Count + filter.Count); foreach (Attribute attribute2 in list) { hashtable[attribute2.TypeId] = attribute2; } foreach (Attribute attribute3 in filter) { hashtable[attribute3.TypeId] = attribute3; } ToolboxItemFilterAttribute[] array = new ToolboxItemFilterAttribute[hashtable.Values.Count]; hashtable.Values.CopyTo(array, 0); return(array); } return(filter); }
public void ConfigureToolboxItem(ToolboxItem item) { if (null == item) { return; } // Create a filter for the Toolbox. ToolboxItemFilterAttribute newFilter; if (typeof(Control1).ToString() == item.TypeName) { // For Control1, only show it when editing a UserControl. newFilter = new ToolboxItemFilterAttribute( "System.Windows.Forms.UserControl", ToolboxItemFilterType.Require); } else if (typeof(Control2).ToString() == item.TypeName) { // For Control2, only show it when not editing a UserControl. newFilter = new ToolboxItemFilterAttribute( "System.Windows.Forms.UserControl", ToolboxItemFilterType.Prevent); } else { // Don't apply a filter to other classes. return; } item.Filter = (ICollection)(new ToolboxItemFilterAttribute[] { newFilter }); }
public TextToolboxNode(string text) { Text = text; //TODO: Use additional filters to limit to a specific host ToolboxItemFilterAttribute[] filters = new ToolboxItemFilterAttribute [1]; filters[0] = new ToolboxItemFilterAttribute("AspNetEdit.RawText", ToolboxItemFilterType.Require); base.ItemFilters = filters; }
public virtual ICollection GetFilter(ICollection creators) { ICollection is2 = this._filter; if (this._filter == null) { if (this._dataObject.GetDataPresent("CF_TOOLBOXITEMCONTAINER")) { byte[] data = (byte[])this._dataObject.GetData("CF_TOOLBOXITEMCONTAINER"); if (data != null) { BinaryReader reader = new BinaryReader(new MemoryStream(data)); if (reader.ReadInt16() != 1) { this._filter = new ToolboxItemFilterAttribute[0]; } else { short num2 = reader.ReadInt16(); ToolboxItemFilterAttribute[] attributeArray = new ToolboxItemFilterAttribute[num2]; for (short i = 0; i < num2; i = (short)(i + 1)) { string filterString = reader.ReadString(); short num4 = reader.ReadInt16(); attributeArray[i] = new ToolboxItemFilterAttribute(filterString, (ToolboxItemFilterType)num4); } this._filter = attributeArray; } } else { this._filter = new ToolboxItemFilterAttribute[0]; } return(this._filter); } if (creators != null) { foreach (ToolboxItemCreator creator in creators) { if (this._dataObject.GetDataPresent(creator.Format)) { ToolboxItem item = creator.Create(this._dataObject); if (item != null) { return(MergeFilter(item)); } } } } } return(is2); }
// Determine if two attribute values have matching filter strings. public override bool Match(Object obj) { ToolboxItemFilterAttribute other = (obj as ToolboxItemFilterAttribute); if (other != null) { return(filterString == other.filterString); } else { return(false); } }
public static IEnumerable <object[]> Match_TestData() { var attribute = new ToolboxItemFilterAttribute("filterString", ToolboxItemFilterType.Allow); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new ToolboxItemFilterAttribute("filterString", ToolboxItemFilterType.Allow), true }); yield return(new object[] { attribute, new ToolboxItemFilterAttribute("filterstring", ToolboxItemFilterType.Allow), false }); yield return(new object[] { attribute, new ToolboxItemFilterAttribute("filterString", ToolboxItemFilterType.Custom), true }); yield return(new object[] { attribute, new object(), false }); yield return(new object[] { attribute, null, false }); }
/// <summary> /// Add a filter to the specified <see cref="ModelingToolboxItem"/> /// </summary> /// <param name="items">A list of existing items</param> /// <param name="itemIndexDictionary">A dictionary mapping from the item identifier to an index in the /// <paramref name="items"/> list. The dictionary should be created with <see cref="CreateIdentifierToIndexMap"/></param> /// <param name="itemId">The identifer of the item to modify</param> /// <param name="filterAttribute">The filter attribute to add</param> public static void AddFilterAttribute(IList <ModelingToolboxItem> items, IDictionary <string, int> itemIndexDictionary, string itemId, ToolboxItemFilterAttribute filterAttribute) { int itemIndex; if (itemIndexDictionary.TryGetValue(itemId, out itemIndex)) { ModelingToolboxItem itemBase = items[itemIndex]; ICollection baseFilters = itemBase.Filter; int baseFilterCount = (baseFilters != null) ? baseFilters.Count : 0; ToolboxItemFilterAttribute[] newFilters = new ToolboxItemFilterAttribute[baseFilterCount + 1]; if (baseFilterCount != 0) { baseFilters.CopyTo(newFilters, 0); } newFilters[baseFilterCount] = filterAttribute; itemBase.Filter = newFilters; } }
protected virtual object ValidatePropertyValue(string propertyName, object value) { switch (propertyName) { case "AssemblyName": ValidatePropertyType(propertyName, value, typeof(AssemblyName), true); break; case "Bitmap": ValidatePropertyType(propertyName, value, typeof(Bitmap), true); break; case "Company": case "Description": case "DisplayName": case "TypeName": ValidatePropertyType(propertyName, value, typeof(string), true); if (value == null) { value = String.Empty; } break; case "IsTransient": ValidatePropertyType(propertyName, value, typeof(bool), false); break; case "Filter": ValidatePropertyType(propertyName, value, typeof(ToolboxItemFilterAttribute[]), true); if (value == null) { value = new ToolboxItemFilterAttribute [0]; } break; case "DependentAssemblies": ValidatePropertyType(propertyName, value, typeof(AssemblyName[]), true); break; default: break; } return(value); }
/// <summary> /// Remove a filter from the specified <see cref="ModelingToolboxItem"/> /// </summary> /// <param name="items">A list of existing items</param> /// <param name="itemIndexDictionary">A dictionary mapping from the item identifier to an index in the /// <paramref name="items"/> list. The dictionary should be created with <see cref="CreateIdentifierToIndexMap"/></param> /// <param name="itemId">The identifer of the item to modify</param> /// <param name="filterString">The filter string for the filter to remove</param> public static void RemoveFilterAttribute(IList <ModelingToolboxItem> items, IDictionary <string, int> itemIndexDictionary, string itemId, string filterString) { int itemIndex; if (itemIndexDictionary.TryGetValue(itemId, out itemIndex)) { ModelingToolboxItem itemBase = items[itemIndex]; ICollection baseFilters = itemBase.Filter; int baseFilterCount = baseFilters.Count; if (baseFilterCount != 0) { int removeCount = 0; foreach (object filter in baseFilters) { ToolboxItemFilterAttribute filterAttribute = filter as ToolboxItemFilterAttribute; if (filterAttribute == null || filterAttribute.FilterString == filterString) { ++removeCount; } } if (removeCount == baseFilterCount) { itemBase.Filter = null; } else { ToolboxItemFilterAttribute[] newFilters = new ToolboxItemFilterAttribute[baseFilterCount - removeCount]; int nextIndex = 0; foreach (object filter in baseFilters) { ToolboxItemFilterAttribute filterAttribute = filter as ToolboxItemFilterAttribute; if (filterAttribute != null && filterAttribute.FilterString != filterString) { newFilters[nextIndex] = filterAttribute; ++nextIndex; } } itemBase.Filter = newFilters; } } } }
//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."); }
/// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.FilterPropertyValue"]/*' /> /// <devdoc> /// Filters a property value before returning it. This allows a property to always clone values, /// or to provide a default value when none exists. /// </devdoc> protected virtual object FilterPropertyValue(string propertyName, object value) { switch (propertyName) { case "AssemblyName": if (value != null) { value = ((AssemblyName)value).Clone(); } break; case "DisplayName": case "TypeName": if (value == null) { value = string.Empty; } break; case "Filter": if (value == null) { value = new ToolboxItemFilterAttribute[0]; } break; case "IsTransient": if (value == null) { value = false; } break; } return(value); }
protected virtual object FilterPropertyValue(string propertyName, object value) { string str = propertyName; if (str != null) { if (!(str == "AssemblyName")) { if ((str == "DisplayName") || (str == "TypeName")) { if (value == null) { value = string.Empty; } return(value); } if (str == "Filter") { if (value == null) { value = new ToolboxItemFilterAttribute[0]; } return(value); } if ((str == "IsTransient") && (value == null)) { value = false; } return(value); } if (value != null) { value = ((System.Reflection.AssemblyName)value).Clone(); } } return(value); }
//evaluate a filter attribute against a list, and check whether permitted private bool FilterPermitted(ItemToolboxNode node, ToolboxItemFilterAttribute desFa, ICollection <ToolboxItemFilterAttribute> filterAgainst, IToolboxConsumer consumer) { switch (desFa.FilterType) { case ToolboxItemFilterType.Allow: //this is really for matching some other filter string against return(true); case ToolboxItemFilterType.Custom: return(consumer.CustomFilterSupports(node)); 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."); }
public void AddToolboxFilter(ToolboxItemFilterAttribute filter) { customToolboxFilters.Add(filter); }
public void GetHashCode_Invoke_ReturnsConsistentValue() { var attribute = new ToolboxItemFilterAttribute("filterString"); Assert.Equal(attribute.GetHashCode(), attribute.GetHashCode()); }
public void Equals_Object_ReturnsExpected(ToolboxItemFilterAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); }
public virtual void Initialize(Type type) { this.CheckUnlocked(); if (type != null) { this.TypeName = type.FullName; System.Reflection.AssemblyName name = type.Assembly.GetName(true); if (type.Assembly.GlobalAssemblyCache) { name.CodeBase = null; } Dictionary <string, System.Reflection.AssemblyName> dictionary = new Dictionary <string, System.Reflection.AssemblyName>(); for (Type type2 = type; type2 != null; type2 = type2.BaseType) { System.Reflection.AssemblyName policiedAssemblyName = type2.Assembly.GetName(true); System.Reflection.AssemblyName nonRetargetedAssemblyName = this.GetNonRetargetedAssemblyName(type, policiedAssemblyName); if ((nonRetargetedAssemblyName != null) && !dictionary.ContainsKey(nonRetargetedAssemblyName.FullName)) { dictionary[nonRetargetedAssemblyName.FullName] = nonRetargetedAssemblyName; } } System.Reflection.AssemblyName[] nameArray = new System.Reflection.AssemblyName[dictionary.Count]; int num = 0; foreach (System.Reflection.AssemblyName name4 in dictionary.Values) { nameArray[num++] = name4; } this.DependentAssemblies = nameArray; this.AssemblyName = name; this.DisplayName = type.Name; if (!type.Assembly.ReflectionOnly) { object[] customAttributes = type.Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true); if ((customAttributes != null) && (customAttributes.Length > 0)) { AssemblyCompanyAttribute attribute = customAttributes[0] as AssemblyCompanyAttribute; if ((attribute != null) && (attribute.Company != null)) { this.Company = attribute.Company; } } DescriptionAttribute attribute2 = (DescriptionAttribute)TypeDescriptor.GetAttributes(type)[typeof(DescriptionAttribute)]; if (attribute2 != null) { this.Description = attribute2.Description; } ToolboxBitmapAttribute attribute3 = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)]; if (attribute3 != null) { System.Drawing.Bitmap image = attribute3.GetImage(type, false) as System.Drawing.Bitmap; if ((image != null) && ((image.Width != 0x10) || (image.Height != 0x10))) { image = new System.Drawing.Bitmap(image, new Size(0x10, 0x10)); } this.Bitmap = image; } bool flag = false; ArrayList list = new ArrayList(); foreach (Attribute attribute4 in TypeDescriptor.GetAttributes(type)) { ToolboxItemFilterAttribute attribute5 = attribute4 as ToolboxItemFilterAttribute; if (attribute5 != null) { if (attribute5.FilterString.Equals(this.TypeName)) { flag = true; } list.Add(attribute5); } } if (!flag) { list.Add(new ToolboxItemFilterAttribute(this.TypeName)); } this.Filter = (ToolboxItemFilterAttribute[])list.ToArray(typeof(ToolboxItemFilterAttribute)); } } }
protected virtual object ValidatePropertyValue(string propertyName, object value) { switch (propertyName) { case "AssemblyName": this.ValidatePropertyType(propertyName, value, typeof(System.Reflection.AssemblyName), true); return(value); case "Bitmap": this.ValidatePropertyType(propertyName, value, typeof(System.Drawing.Bitmap), true); return(value); case "Company": case "Description": case "DisplayName": case "TypeName": this.ValidatePropertyType(propertyName, value, typeof(string), true); if (value == null) { value = string.Empty; } return(value); case "Filter": { this.ValidatePropertyType(propertyName, value, typeof(ICollection), true); int num = 0; ICollection is2 = (ICollection)value; if (is2 != null) { foreach (object obj2 in is2) { if (obj2 is ToolboxItemFilterAttribute) { num++; } } } ToolboxItemFilterAttribute[] attributeArray = new ToolboxItemFilterAttribute[num]; if (is2 != null) { num = 0; foreach (object obj3 in is2) { ToolboxItemFilterAttribute attribute = obj3 as ToolboxItemFilterAttribute; if (attribute != null) { attributeArray[num++] = attribute; } } } value = attributeArray; return(value); } case "IsTransient": this.ValidatePropertyType(propertyName, value, typeof(bool), false); return(value); } return(value); }
public void ToString_Invoke_ReturnsExpected(string filterString, ToolboxItemFilterType filterType, string expected) { var attribute = new ToolboxItemFilterAttribute(filterString, filterType); Assert.Equal(expected, attribute.ToString()); }
/// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.ValidatePropertyValue"]/*' /> /// <devdoc> /// This is called whenever a value is set in the property dictionary. It gives you a chance /// to change the value of an object before comitting it, our reject it by throwing an /// exception. /// </devdoc> protected virtual object ValidatePropertyValue(string propertyName, object value) { switch (propertyName) { case "AssemblyName": ValidatePropertyType(propertyName, value, typeof(AssemblyName), true); break; case "Bitmap": ValidatePropertyType(propertyName, value, typeof(Bitmap), true); break; case "OriginalBitmap": ValidatePropertyType(propertyName, value, typeof(Bitmap), true); break; case "Company": case "Description": case "DisplayName": case "TypeName": ValidatePropertyType(propertyName, value, typeof(string), true); if (value == null) { value = string.Empty; } break; case "Filter": ValidatePropertyType(propertyName, value, typeof(ICollection), true); int filterCount = 0; ICollection col = (ICollection)value; if (col != null) { foreach (object f in col) { if (f is ToolboxItemFilterAttribute) { filterCount++; } } } ToolboxItemFilterAttribute[] filter = new ToolboxItemFilterAttribute[filterCount]; if (col != null) { filterCount = 0; foreach (object f in col) { ToolboxItemFilterAttribute tfa = f as ToolboxItemFilterAttribute; if (tfa != null) { filter[filterCount++] = tfa; } } } value = filter; break; case "IsTransient": ValidatePropertyType(propertyName, value, typeof(bool), false); break; } return(value); }
public virtual void Initialize(Type type) { CheckUnlocked(); if (type != null) { TypeName = type.FullName; AssemblyName assemblyName = type.Assembly.GetName(true); if (type.Assembly.GlobalAssemblyCache) { assemblyName.CodeBase = null; } Dictionary <string, AssemblyName> parents = new Dictionary <string, AssemblyName>(); Type parentType = type; while (parentType != null) { AssemblyName policiedname = parentType.Assembly.GetName(true); AssemblyName aname = GetNonRetargetedAssemblyName(type, policiedname); if (aname != null && !parents.ContainsKey(aname.FullName)) { parents[aname.FullName] = aname; } parentType = parentType.BaseType; } AssemblyName[] parentAssemblies = new AssemblyName[parents.Count]; int i = 0; foreach (AssemblyName an in parents.Values) { parentAssemblies[i++] = an; } this.DependentAssemblies = parentAssemblies; AssemblyName = assemblyName; DisplayName = type.Name; //if the Type is a reflectonly type, these values must be set through a config object or manually //after construction. if (!type.Assembly.ReflectionOnly) { object[] companyattrs = type.Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true); if (companyattrs != null && companyattrs.Length > 0) { AssemblyCompanyAttribute company = companyattrs[0] as AssemblyCompanyAttribute; if (company != null && company.Company != null) { Company = company.Company; } } //set the description based off the description attribute of the given type. DescriptionAttribute descattr = (DescriptionAttribute)TypeDescriptor.GetAttributes(type)[typeof(DescriptionAttribute)]; if (descattr != null) { this.Description = descattr.Description; } ToolboxBitmapAttribute attr = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)]; if (attr != null) { Bitmap itemBitmap = attr.GetImage(type, false) as Bitmap; if (itemBitmap != null) { // Original bitmap is used when adding the item to the Visual Studio toolbox // if running on a machine with HDPI scaling enabled. OriginalBitmap = attr.GetOriginalBitmap(); if ((itemBitmap.Width != iconWidth || itemBitmap.Height != iconHeight)) { itemBitmap = new Bitmap(itemBitmap, new Size(iconWidth, iconHeight)); } } Bitmap = itemBitmap; } bool filterContainsType = false; ArrayList array = new ArrayList(); foreach (Attribute a in TypeDescriptor.GetAttributes(type)) { ToolboxItemFilterAttribute ta = a as ToolboxItemFilterAttribute; if (ta != null) { if (ta.FilterString.Equals(TypeName)) { filterContainsType = true; } array.Add(ta); } } if (!filterContainsType) { array.Add(new ToolboxItemFilterAttribute(TypeName)); } Filter = (ToolboxItemFilterAttribute[])array.ToArray(typeof(ToolboxItemFilterAttribute)); } } }
private bool Update() { bool flag = false; IDesigner designer = null; IComponent primarySelection = this._selectionService.PrimarySelection as IComponent; if (primarySelection != null) { designer = this._host.GetDesigner(primarySelection); } if (designer == null) { primarySelection = this._host.RootComponent; if (primarySelection != null) { designer = this._host.GetDesigner(primarySelection); } } if (designer != this._filterDesigner) { ArrayList list; if (designer != null) { AttributeCollection designerAttributes = this.GetDesignerAttributes(designer); list = new ArrayList(designerAttributes.Count); foreach (Attribute attribute in designerAttributes) { if (attribute is ToolboxItemFilterAttribute) { list.Add(attribute); } } } else { list = new ArrayList(); } if (this._filter == null) { flag = true; } else if (this._filter.Count != list.Count) { flag = true; } else { IEnumerator enumerator = this._filter.GetEnumerator(); IEnumerator enumerator2 = list.GetEnumerator(); while (enumerator2.MoveNext()) { enumerator.MoveNext(); if (!enumerator2.Current.Equals(enumerator.Current)) { flag = true; break; } ToolboxItemFilterAttribute current = (ToolboxItemFilterAttribute)enumerator2.Current; if (current.FilterType == ToolboxItemFilterType.Custom) { flag = true; break; } } } this._filter = list; this._filterDesigner = designer; this._toolboxUser = this._filterDesigner as IToolboxUser; if (this._toolboxUser == null) { IDesigner parent; for (ITreeDesigner designer2 = this._filterDesigner as ITreeDesigner; (this._toolboxUser == null) && (designer2 != null); designer2 = parent as ITreeDesigner) { parent = designer2.Parent; this._toolboxUser = parent as IToolboxUser; } } if ((this._toolboxUser == null) && (this._host.RootComponent != null)) { this._toolboxUser = this._host.GetDesigner(this._host.RootComponent) as IToolboxUser; } } if (this._filter == null) { this._filter = new ArrayList(); } return(flag); }
private static FilterSupport GetFilterSupport(ICollection itemFilter, ICollection targetFilter) { FilterSupport supported = FilterSupport.Supported; int num = 0; int num2 = 0; foreach (ToolboxItemFilterAttribute attribute in itemFilter) { if (supported == FilterSupport.NotSupported) { break; } if (attribute.FilterType == ToolboxItemFilterType.Require) { num++; foreach (object obj2 in targetFilter) { ToolboxItemFilterAttribute attribute2 = obj2 as ToolboxItemFilterAttribute; if ((attribute2 != null) && attribute.Match(attribute2)) { num2++; break; } } } else if (attribute.FilterType == ToolboxItemFilterType.Prevent) { foreach (object obj3 in targetFilter) { ToolboxItemFilterAttribute attribute3 = obj3 as ToolboxItemFilterAttribute; if ((attribute3 != null) && attribute.Match(attribute3)) { supported = FilterSupport.NotSupported; break; } } } else if ((supported != FilterSupport.Custom) && (attribute.FilterType == ToolboxItemFilterType.Custom)) { if (attribute.FilterString.Length == 0) { supported = FilterSupport.Custom; } else { foreach (ToolboxItemFilterAttribute attribute4 in targetFilter) { if (attribute.FilterString.Equals(attribute4.FilterString)) { supported = FilterSupport.Custom; break; } } } } } if (((supported != FilterSupport.NotSupported) && (num > 0)) && (num2 == 0)) { supported = FilterSupport.NotSupported; } if (supported != FilterSupport.NotSupported) { num = 0; num2 = 0; foreach (ToolboxItemFilterAttribute attribute5 in targetFilter) { if (supported == FilterSupport.NotSupported) { break; } if (attribute5.FilterType == ToolboxItemFilterType.Require) { num++; foreach (ToolboxItemFilterAttribute attribute6 in itemFilter) { if (attribute5.Match(attribute6)) { num2++; break; } } } else if (attribute5.FilterType == ToolboxItemFilterType.Prevent) { foreach (ToolboxItemFilterAttribute attribute7 in itemFilter) { if (attribute5.Match(attribute7)) { supported = FilterSupport.NotSupported; break; } } } else if ((supported != FilterSupport.Custom) && (attribute5.FilterType == ToolboxItemFilterType.Custom)) { if (attribute5.FilterString.Length == 0) { supported = FilterSupport.Custom; } else { foreach (ToolboxItemFilterAttribute attribute8 in itemFilter) { if (attribute5.FilterString.Equals(attribute8.FilterString)) { supported = FilterSupport.Custom; break; } } } } } if (((supported != FilterSupport.NotSupported) && (num > 0)) && (num2 == 0)) { supported = FilterSupport.NotSupported; } } return(supported); }