return ImportMembersMapping (elementName, ns, members, hasWrapperElement, true);
}
-#if NET_2_0
[MonoTODO]
public
-#endif
XmlMembersMapping ImportMembersMapping (string elementName,
string ns,
XmlReflectionMember[] members,
return ImportMembersMapping (elementName, ns, members, hasWrapperElement, rpc, true);
}
-#if NET_2_0
[MonoTODO]
public
-#endif
XmlMembersMapping ImportMembersMapping (string elementName,
string ns,
XmlReflectionMember[] members,
return ImportMembersMapping (elementName, ns, members, hasWrapperElement, rpc, openModel, XmlMappingAccess.Read | XmlMappingAccess.Write);
}
-#if NET_2_0
[MonoTODO] // FIXME: handle writeAccessors, validate, and mapping access
public
-#endif
XmlMembersMapping ImportMembersMapping (string elementName,
string ns,
XmlReflectionMember[] members,
mps.RelatedMaps = relatedMaps;
mps.Format = SerializationFormat.Literal;
Type[] extraTypes = includedTypes != null ? (Type[])includedTypes.ToArray(typeof(Type)) : null;
-#if !NET_2_1
+#if !MOBILE
mps.Source = new MembersSerializationSource (elementName, hasWrapperElement, members, false, true, ns, extraTypes);
if (allowPrivateTypes) mps.Source.CanBeGenerated = false;
#endif
default: throw new NotSupportedException ("Type " + typeData.Type.FullName + " not supported for XML stialization");
}
-#if NET_2_0
// bug #372780
map.SetKey (typeData.Type.ToString ());
-#endif
map.RelatedMaps = relatedMaps;
map.Format = SerializationFormat.Literal;
Type[] extraTypes = includedTypes != null ? (Type[]) includedTypes.ToArray (typeof (Type)) : null;
-#if !NET_2_1
+#if !MOBILE
map.Source = new XmlTypeSerializationSource (typeData.Type, root, attributeOverrides, defaultNamespace, extraTypes);
if (allowPrivateTypes) map.Source.CanBeGenerated = false;
#endif
return map;
}
- XmlTypeMapping ImportClassMapping (Type type, XmlRootAttribute root, string defaultNamespace)
+ XmlTypeMapping ImportClassMapping (Type type, XmlRootAttribute root, string defaultNamespace, bool isBaseType = false)
{
TypeData typeData = TypeTranslator.GetTypeData (type);
- return ImportClassMapping (typeData, root, defaultNamespace);
+ return ImportClassMapping (typeData, root, defaultNamespace, isBaseType);
}
- XmlTypeMapping ImportClassMapping (TypeData typeData, XmlRootAttribute root, string defaultNamespace)
+ XmlTypeMapping ImportClassMapping (TypeData typeData, XmlRootAttribute root, string defaultNamespace, bool isBaseType = false)
{
Type type = typeData.Type;
+ if (!allowPrivateTypes && !isBaseType)
+ ReflectionHelper.CheckSerializableType (type, false);
+
XmlTypeMapping map = helper.GetRegisteredClrType (type, GetTypeNamespace (typeData, root, defaultNamespace));
if (map != null) return map;
-
- if (!allowPrivateTypes)
- ReflectionHelper.CheckSerializableType (type, false);
map = CreateTypeMapping (typeData, root, null, defaultNamespace);
helper.RegisterClrType (map, type, map.XmlTypeNamespace);
string ns = map.XmlTypeNamespace;
if (rmember.XmlAttributes.XmlIgnore) continue;
if (rmember.DeclaringType != null && rmember.DeclaringType != type) {
- XmlTypeMapping bmap = ImportClassMapping (rmember.DeclaringType, root, defaultNamespace);
+ XmlTypeMapping bmap = ImportClassMapping (rmember.DeclaringType, root, defaultNamespace, true);
if (bmap.HasXmlTypeNamespace)
ns = bmap.XmlTypeNamespace;
}
if (type.BaseType != null)
{
- XmlTypeMapping bmap = ImportClassMapping (type.BaseType, root, defaultNamespace);
+ XmlTypeMapping bmap = ImportClassMapping (type.BaseType, root, defaultNamespace, true);
ClassMap cbmap = bmap.ObjectMap as ClassMap;
if (type.BaseType != typeof (object)) {
elem.Form = att.Form;
if (att.Form == XmlSchemaForm.Unqualified)
elem.Namespace = string.Empty;
- elem.IsNullable = att.IsNullable && CanBeNull (elem.TypeData);
+ elem.IsNullable = (!att.IsNullableSpecified || att.IsNullable) && CanBeNull (elem.TypeData);
elem.NestingLevel = att.NestingLevel;
if (isMultiArray) {
// Read all Fields via reflection.
ArrayList fieldList = new ArrayList();
FieldInfo[] tfields = type.GetFields (BindingFlags.Instance | BindingFlags.Public);
-#if TARGET_JVM
- // This statement ensures fields are ordered starting from the base type.
- for (int ti=0; ti<typeList.Count; ti++) {
- for (int i=0; i<tfields.Length; i++) {
- FieldInfo field = tfields[i];
- if (field.DeclaringType == typeList[ti])
- fieldList.Add (field);
- }
- }
-#else
currentType = null;
int currentIndex = 0;
foreach (FieldInfo field in tfields)
}
fieldList.Insert(currentIndex++, field);
}
-#endif
// Read all Properties via reflection.
ArrayList propList = new ArrayList();
PropertyInfo[] tprops = type.GetProperties (BindingFlags.Instance | BindingFlags.Public);
-#if TARGET_JVM
- // This statement ensures properties are ordered starting from the base type.
- for (int ti=0; ti<typeList.Count; ti++) {
- for (int i=0; i<tprops.Length; i++) {
- PropertyInfo prop = tprops[i];
- if (!prop.CanRead) continue;
- if (prop.GetIndexParameters().Length > 0) continue;
- if (prop.DeclaringType == typeList[ti])
- propList.Add (prop);
- }
- }
-#else
currentType = null;
currentIndex = 0;
foreach (PropertyInfo prop in tprops)
if (prop.GetIndexParameters().Length > 0) continue;
propList.Insert(currentIndex++, prop);
}
-#endif
var members = new List<XmlReflectionMember>();
int fieldIndex=0;
int propIndex=0;
if (atts == null) atts = new XmlAttributes (prop);
if (atts.XmlIgnore) continue;
if (!prop.CanWrite) {
+ if (prop.PropertyType.IsInterface && typeof (IEnumerable).IsAssignableFrom (prop.PropertyType)) continue;
if (prop.PropertyType.IsGenericType && TypeData.GetGenericListItemType (prop.PropertyType) == null) continue; // check this before calling GetTypeData() which raises error for missing Add(). See bug #704813.
if (TypeTranslator.GetTypeData (prop.PropertyType).SchemaType != SchemaTypes.Array || prop.PropertyType.IsArray) continue;
}
else
mapAttribute.AttributeName = atts.XmlAttribute.AttributeName;
- mapAttribute.AttributeName = XmlConvert.EncodeLocalName (mapAttribute.AttributeName);
+ mapAttribute.AttributeName = XmlConvert.EncodeName (mapAttribute.AttributeName);
if (typeData.IsComplexType)
mapAttribute.MappedType = ImportTypeMapping (typeData.Type, null, defaultNamespace);
if (choiceEnumMap != null) {
string cname = choiceEnumMap.GetEnumName (choiceEnumType.FullName, elem.ElementName);
+ if (cname == null && elem.Namespace != null)
+ cname = choiceEnumMap.GetEnumName (choiceEnumType.FullName,
+ elem.Namespace.ToString () + ":" + elem.ElementName);
if (cname == null)
throw new InvalidOperationException (string.Format (
CultureInfo.InvariantCulture, "Type {0} is missing"
bool CanBeNull (TypeData type)
{
-#if !NET_2_0 // idiotic compatibility
- if (type.Type == typeof (XmlQualifiedName))
- return false;
-#endif
return !type.Type.IsValueType || type.IsNullable;
}