예제 #1
0
        public static T RemoveAttribute <T>(this T self, FunctionAttributeIndex index, AttributeKind kind)
            where T : class, IAttributeContainer
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            if (kind == AttributeKind.None)
            {
                return(self);
            }

            if (self is IAttributeAccessor container)
            {
                container.RemoveAttributeAtIndex(index, kind);
            }
            else
            {
                IAttributeCollection attributes = self.Attributes[index];
                AttributeValue       attrib     = attributes.FirstOrDefault(a => a.Kind == kind);
                if (attrib != default(AttributeValue))
                {
                    attributes.Remove(attrib);
                }
            }

            return(self);
        }