/// <summary>
        /// Returns the list of all the attributes that need to be propagated to the client
        /// </summary>
        /// <param name="typeAttributes">List of attributes on the type</param>
        /// <returns>List of attributes to be propagated to the client</returns>
        private IEnumerable<Attribute> FilterTypeAttributes(AttributeCollection typeAttributes)
        {
            List<Attribute> filteredAttributes = new List<Attribute>();
            
            // Ignore DefaultMemberAttribute if it has been put for an indexer
            IEnumerable<Attribute> defaultMemberAttribs = typeAttributes.Cast<Attribute>().Where(a => a.GetType() == typeof(DefaultMemberAttribute));
            if (defaultMemberAttribs.Any())
            {
                HashSet<string> properties = new HashSet<string>(TypeDescriptor.GetProperties(this.Type).Cast<PropertyDescriptor>().Select(p => p.Name), StringComparer.Ordinal);
                foreach (DefaultMemberAttribute attrib in defaultMemberAttribs)
                {
                    if (!properties.Contains(attrib.MemberName))
                    {
                        filteredAttributes.Add(attrib);
                    }
                }
            }

            // Filter out attributes in filteredAttributes as well as DataContractAttribute and KnownTypeAttribute (since they are already handled)
            return typeAttributes.Cast<Attribute>().Where(a => a.GetType() != typeof(DataContractAttribute) && a.GetType() != typeof(KnownTypeAttribute) && 
                !(filteredAttributes.Contains(a)));
        }
 public static bool ContainsAttributeType <TAttribute>(this AttributeCollection attributes) where TAttribute : Attribute
 {
     return(attributes.Cast <Attribute>().Any(a => a.GetType() == typeof(TAttribute)));
 }