internal XmlMembersMapping(string elementName, string ns, bool hasWrapperElement, bool writeAccessors, XmlMemberMapping[] mapping) : base(elementName, ns) { _hasWrapperElement = hasWrapperElement; _mapping = mapping; ClassMap map = new ClassMap(); map.IgnoreMemberNamespace = writeAccessors; foreach (XmlMemberMapping mm in mapping) { map.AddMember(mm.TypeMapMember); } ObjectMap = map; }
XmlTypeMapping ImportClassMapping(TypeData typeData, string defaultNamespace) { Type type = typeData.Type; if (type.IsValueType) { throw CreateStructException(type); } if (type == typeof(object)) { defaultNamespace = XmlSchema.Namespace; } ReflectionHelper.CheckSerializableType(type, false); XmlTypeMapping map = helper.GetRegisteredClrType(type, GetTypeNamespace(typeData, defaultNamespace)); if (map != null) { return(map); } map = CreateTypeMapping(typeData, null, defaultNamespace); helper.RegisterClrType(map, type, map.Namespace); map.MultiReferenceType = true; ClassMap classMap = new ClassMap(); map.ObjectMap = classMap; // Import members ICollection members = GetReflectionMembers(type); foreach (XmlReflectionMember rmember in members) { if (rmember.SoapAttributes.SoapIgnore) { continue; } classMap.AddMember(CreateMapMember(rmember, defaultNamespace)); } // Import included classes SoapIncludeAttribute[] includes = (SoapIncludeAttribute[])type.GetCustomAttributes(typeof(SoapIncludeAttribute), false); for (int n = 0; n < includes.Length; n++) { Type includedType = includes[n].Type; ImportTypeMapping(includedType); } if (type == typeof(object) && includedTypes != null) { foreach (Type intype in includedTypes) { map.DerivedTypes.Add(ImportTypeMapping(intype)); } } // Register inheritance relations if (type.BaseType != null) { XmlTypeMapping bmap = ImportClassMapping(type.BaseType, defaultNamespace); if (type.BaseType != typeof(object)) { map.BaseMap = bmap; } // At this point, derived classes of this map must be already registered RegisterDerivedMap(bmap, map); } return(map); }