Ejemplo n.º 1
0
		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);
		}
Ejemplo n.º 2
0
        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);
        }