+2003-03-17 Miguel de Icaza <miguel@ximian.com>
+
+ * XmlSerializer.cs: Do not use Bubblesort, use ArrayList.Sort.
+ Kill Bublesort.
+
2003-03-22 Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
* XmlSerializer.cs : patch by Sean Cier. Serialize() other than
* XmlSerializer.cs : Serialize() don't write xmldecl when WriteState is
not WriteState.Start, and never call WriteEndDocument().
+>>>>>>> 1.26
2003-03-12 Elan Feingold <efeingold@mn.rr.com>
* XmlCustomFormatter.cs: Correct signature, Implement
ref Object theObject,
String fieldName)
{
- // Get the type
+ //Console.WriteLine("DeserializeField({0})", fieldName);
+
+ Type fieldType = null;
+ BindingFlags bindingFlags = 0;
+
+ // Get the type, first try a field.
FieldInfo fieldInfo = theObject.GetType().GetField(fieldName);
- Type fieldType = fieldInfo.FieldType;
+ if (fieldInfo != null)
+ {
+ fieldType = fieldInfo.FieldType;
+ bindingFlags = BindingFlags.SetField;
+ }
+ else
+ {
+ // Is it a property?
+ PropertyInfo propInfo = theObject.GetType().GetProperty(fieldName);
+ if (propInfo != null)
+ {
+ fieldType = propInfo.PropertyType;
+ bindingFlags = BindingFlags.SetProperty;
+ }
+ }
+
Object value = null;
bool isEmptyField = xmlReader.IsEmptyElement;
- //Console.WriteLine("DeserializeField({0} of type {1}", fieldName, fieldType);
+ //Console.WriteLine("DeserializeField({0} of type {1})", fieldName, fieldType);
if (fieldType.IsArray && fieldType != typeof(System.Byte[]))
{
DeserializeArray(xmlReader, list, fieldType.GetElementType());
value = list.ToArray(fieldType.GetElementType());
}
- else if (isEmptyField == true && fieldType.IsArray)
- {
- // Must be a byte array, just create an empty one.
- value = new byte[0];
- }
else if (isEmptyField == false &&
- (IsInbuiltType(fieldType) || fieldType.IsEnum || fieldType.IsArray))
+ (IsInbuiltType(fieldType) ||
+ fieldType.IsEnum ||
+ fieldType.IsArray))
{
// Built in, set it.
while (xmlReader.Read())
}
}
}
+ else if (isEmptyField == true)
+ {
+ if (fieldType.IsArray)
+ {
+ // Must be a byte array, just create an empty one.
+ value = new byte[0];
+ }
+ else if (fieldType == typeof(string))
+ {
+ // Create a new empty string.
+ value = "";
+ }
+ }
else
{
//Console.WriteLine("Creating new {0}", fieldType);
// Set the field value.
theObject.GetType().InvokeMember(fieldName,
- BindingFlags.SetField,
+ bindingFlags,
null,
theObject,
new Object[] { value },