GetFirstApplicableAttribute() public méthode

public GetFirstApplicableAttribute ( Type type ) : XmlSerializationAttribute
type System.Type
Résultat XmlSerializationAttribute
		public ListTypeSerializer(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
			: base(memberInfo, memberInfo.ReturnType, cache, options)
		{
			typeToItemMap = new Dictionary<Type, ListItem>();
			aliasToItemMap = new Dictionary<string, ListItem>();

			var attribute = (XmlListElementDynamicTypeProviderAttribute)memberInfo.GetFirstApplicableAttribute(typeof(XmlListElementDynamicTypeProviderAttribute));

			if (attribute != null)
			{
				if (dynamicTypeResolver == null)
				{
					try
					{
						dynamicTypeResolver  = (IXmlListElementDynamicTypeProvider)Activator.CreateInstance(attribute.ProviderType, new object[0]);
					}
					catch (Exception)
					{
					}
				}

				if (dynamicTypeResolver == null)
				{
					dynamicTypeResolver = (IXmlListElementDynamicTypeProvider)Activator.CreateInstance(attribute.ProviderType, new object[] {memberInfo, cache, options});
				}
			}

			serializationMemberInfo = memberInfo;

			this.cache = cache;

			Scan(memberInfo, cache, options);
		}
        public ListTypeSerializer(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
            : base(memberInfo, memberInfo.ReturnType, cache, options)
        {
            typeToItemMap = new Dictionary<Type, ListItem>();
            aliasToItemMap = new Dictionary<string, ListItem>();

            var attribute = (XmlListElementDynamicTypeProviderAttribute)memberInfo.GetFirstApplicableAttribute(typeof(XmlListElementDynamicTypeProviderAttribute));

            if (attribute != null)
            {
                if (dynamicTypeResolver == null)
                {
                    try
                    {
                        dynamicTypeResolver  = (IXmlListElementDynamicTypeProvider)Activator.CreateInstance(attribute.ProviderType, new object[0]);
                    }
                    catch (Exception)
                    {
                    }
                }

                if (dynamicTypeResolver == null)
                {
                    dynamicTypeResolver = (IXmlListElementDynamicTypeProvider)Activator.CreateInstance(attribute.ProviderType, new object[] {memberInfo, cache, options});
                }
            }

            serializationMemberInfo = memberInfo;

            this.cache = cache;

            Scan(memberInfo, cache, options);
        }
Exemple #3
0
        public StringableTypeSerializer(Type type, SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
        {
            supportedType = type;
            if (memberInfo != null)
            {
                formatAttribute = (XmlFormatAttribute)memberInfo.GetFirstApplicableAttribute(typeof(XmlFormatAttribute));
            }

            formatSpecified = formatAttribute != null;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="memberInfo"></param>
        /// <param name="cache"></param>
        /// <param name="options"></param>
        public DateTimeTypeSerializer(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
        {
            m_FormatAttribute = (XmlDateTimeFormatAttribute)memberInfo.GetFirstApplicableAttribute(typeof(XmlDateTimeFormatAttribute));

            if (m_FormatAttribute == null)
            {
                m_FormatAttribute = new XmlDateTimeFormatAttribute("G");
                m_FormatSpecified = false;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="memberInfo"></param>
        /// <param name="cache"></param>
        /// <param name="options"></param>
        public DateTimeTypeSerializer(SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
        {
            m_FormatAttribute = (XmlDateTimeFormatAttribute)memberInfo.GetFirstApplicableAttribute(typeof(XmlDateTimeFormatAttribute));

            if (m_FormatAttribute == null)
            {
                m_FormatAttribute = new XmlDateTimeFormatAttribute("G");
                m_FormatSpecified = false;
            }
        }
        public StringableTypeSerializer(Type type, SerializationMemberInfo memberInfo, TypeSerializerCache cache, SerializerOptions options)
        {
            supportedType = type;
            if (memberInfo != null)
            {
                formatAttribute= (XmlFormatAttribute) memberInfo.GetFirstApplicableAttribute(typeof (XmlFormatAttribute));
            }

            formatSpecified = formatAttribute != null;
        }