Platform.Xml.Serialization.SerializationMemberInfo.GetAttributeDeclaringType C# (CSharp) Method

GetAttributeDeclaringType() private static method

private static GetAttributeDeclaringType ( Type type, Attribute attribute ) : Type
type System.Type
attribute System.Attribute
return System.Type
        private static Type GetAttributeDeclaringType(Type type, Attribute attribute)
        {
            while (true)
            {
                var attributes = type.GetCustomAttributes(attribute.GetType(), false);

                foreach (Attribute a in attributes)
                {
                    if (a.Equals(attribute))
                    {
                        return type;
                    }
                }

                type = type.BaseType;

                if (type == null)
                {
                    break;
                }
            }

            return null;
        }