System.ComponentModel.MemberDescriptor.FilterAttributesIfNeeded C# (CSharp) Method

FilterAttributesIfNeeded() private method

private FilterAttributesIfNeeded ( ) : void
return void
        private void FilterAttributesIfNeeded()
        {
            if (!_attributesFiltered)
            {
                List<Attribute> list;

                if (!_attributesFilled)
                {
                    list = new List<Attribute>();
                    try
                    {
                        FillAttributes(list);
                    }
                    catch (Exception e)
                    {
                        Debug.Fail($"{_name}>>{e}");
                    }
                }
                else
                {
                    list = new List<Attribute>(_attributes);
                }

                var set = new HashSet<object>();

                for (int i = 0; i < list.Count;)
                {
                    if (set.Add(list[i].TypeId))
                    {
                        ++i;
                    }
                    else
                    {
                        list.RemoveAt(i);
                    }
                }

                Attribute[] newAttributes = list.ToArray();

                lock (_lockCookie)
                {
                    _attributes = newAttributes;
                    _attributesFiltered = true;
                    _attributesFilled = true;
                    _metadataVersion = TypeDescriptor.MetadataVersion;
                }
            }
        }

Usage Example

Example #1
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (obj.GetType() != base.GetType())
            {
                return(false);
            }
            MemberDescriptor descriptor = (MemberDescriptor)obj;

            this.FilterAttributesIfNeeded();
            descriptor.FilterAttributesIfNeeded();
            if (descriptor.nameHash != this.nameHash)
            {
                return(false);
            }
            if (((descriptor.category == null) != (this.category == null)) || ((this.category != null) && !descriptor.category.Equals(this.category)))
            {
                return(false);
            }
            if (((descriptor.description == null) != (this.description == null)) || ((this.description != null) && !descriptor.category.Equals(this.description)))
            {
                return(false);
            }
            if ((descriptor.attributes == null) != (this.attributes == null))
            {
                return(false);
            }
            if (this.attributes != null)
            {
                if (this.attributes.Length != descriptor.attributes.Length)
                {
                    return(false);
                }
                for (int i = 0; i < this.attributes.Length; i++)
                {
                    if (!this.attributes[i].Equals(descriptor.attributes[i]))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
All Usage Examples Of System.ComponentModel.MemberDescriptor::FilterAttributesIfNeeded