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

GetApplicableAttributes() public method

public GetApplicableAttributes ( Type types ) : Platform.Xml.Serialization.XmlSerializationAttribute[]
types System.Type
return Platform.Xml.Serialization.XmlSerializationAttribute[]
        public virtual XmlSerializationAttribute[] GetApplicableAttributes(Type[] types)
        {
            return GetApplicableAttributes(true, types);
        }

Same methods

SerializationMemberInfo::GetApplicableAttributes ( bool includeTypeAttributes, Type types ) : Platform.Xml.Serialization.XmlSerializationAttribute[]
SerializationMemberInfo::GetApplicableAttributes ( bool includeTypeAttributes, bool includeAttributeSubclasses, Type types ) : Platform.Xml.Serialization.XmlSerializationAttribute[]

Usage Example

        private void Scan(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
        {
            XmlSerializationAttribute[] attribs;

            var attributes = new List<Attribute>();

            // Get the ElementType attributes specified on the type itself as long
            // as we're not the type itself!

            if (memberInfo.MemberInfo != memberInfo.ReturnType)
            {
                var smi = new SerializationMemberInfo(memberInfo.ReturnType, options, cache);

                attribs = smi.GetApplicableAttributes(typeof(XmlDictionaryElementTypeAttribute));

                foreach (XmlSerializationAttribute a in attribs)
                {
                    attributes.Add(a);
                }
            }

            // Get the ElementType attributes specified on the member.

            attribs = memberInfo.GetApplicableAttributes(typeof(XmlDictionaryElementTypeAttribute));

            foreach (var a in attribs)
            {
                attributes.Add(a);
            }

            foreach (XmlDictionaryElementTypeAttribute attribute in attributes)
            {
                var dictionaryItem = new DictionaryItem();

                var smi2 = new SerializationMemberInfo(attribute.ElementType, options, cache);

                if (attribute.TypeAlias == null)
                {
                    attribute.TypeAlias = smi2.SerializedName;
                }

                dictionaryItem.attribute = attribute;
                dictionaryItem.typeAlias = attribute.TypeAlias;

                // Check if a specific type of serializer is specified.

                if (attribute.SerializerType == null)
                {
                    // Figure out the serializer based on the type of the element.

                    dictionaryItem.serializer = cache.GetTypeSerializerBySupportedType(attribute.ElementType, smi2);
                }
                else
                {
                    // Get the type of serializer they specify.

                    dictionaryItem.serializer = cache.GetTypeSerializerBySerializerType(attribute.SerializerType, smi2);
                }

                primaryDictionaryItem = dictionaryItem;

                typeToItemMap[attribute.ElementType] = dictionaryItem;
                aliasToItemMap[attribute.TypeAlias] = dictionaryItem;
            }

            if (aliasToItemMap.Count != 1)
            {
                primaryDictionaryItem = null;
            }
        }
All Usage Examples Of Platform.Xml.Serialization.SerializationMemberInfo::GetApplicableAttributes