private void ConvertObject(object value) { if (value == null) { // TODO: Make this a configuration option // Don't export null values. return; } if (alreadySerialised.ContainsKey(value)) { // Reference by ID, not path writer.WriteAttribute(Attributes.reference, alreadySerialised[value]); } else { // Store the ID of the object int index = alreadySerialised.Count + 1; alreadySerialised.Add(value, index.ToString()); // Write attribute for own id writer.WriteAttribute(Attributes.id, index.ToString()); new Marshaller(writer, this).Marshal(value); } }
private void ConvertObject(object value) { if (alreadySerialised.ContainsKey(value)) { writer.WriteAttribute(Attributes.references, alreadySerialised[value]); } else { alreadySerialised.Add(value, writer.CurrentPath); new Marshaller(writer, this).Marshal(value); } }
public void Marshall(object value, XStreamWriter writer, MarshallingContext context) { IList list = (IList) value; writer.WriteAttribute(LIST_TYPE, value.GetType().FullName); foreach (object o in list) context.ConvertOriginal(o); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { Array array = (Array) value; string typeName = value.GetType().AssemblyQualifiedName; int lastIndexOfBrackets = typeName.LastIndexOf("[]"); string arrayType = string.Concat(typeName.Substring(0, lastIndexOfBrackets), typeName.Substring(lastIndexOfBrackets + 2)); writer.WriteAttribute(ARRAY_TYPE, arrayType); foreach (object o in array) context.ConvertOriginal(o); }
public void WriteValueOn(XStreamWriter writer, object value) { writer.StartNode(SerializedName); object fieldValue = GetObjectFrom(value); if (fieldValue == null) return; Type actualType = fieldValue.GetType(); if (!FieldType.Equals(actualType)) writer.WriteAttribute(XsAttribute.classType, actualType.AssemblyQualifiedName); }
private static void WriteNode(XStreamWriter writer, MarshallingContext context, string node, object value) { writer.StartNode(node); Type type = value != null?value.GetType() : typeof(object); writer.WriteAttribute(Attributes.classType, type.AssemblyQualifiedName); context.ConvertAnother(value); writer.EndNode(); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { IList list = (IList)value; writer.WriteAttribute(LIST_TYPE, value.GetType().FullName); foreach (object o in list) { context.ConvertOriginal(o); } }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { Array array = (Array)value; string typeName = value.GetType().AssemblyQualifiedName; int lastIndexOfBrackets = typeName.LastIndexOf("[]"); string arrayType = string.Concat(typeName.Substring(0, lastIndexOfBrackets), typeName.Substring(lastIndexOfBrackets + 2)); writer.WriteAttribute(ARRAY_TYPE, arrayType); foreach (object o in array) { context.ConvertOriginal(o); } }
private void WriteClassNameIfNeedBe(object value, FieldInfo field) { object fieldValue = field.GetValue(value); if (fieldValue == null) { return; } Type actualType = fieldValue.GetType(); if (!field.FieldType.Equals(actualType)) { writer.WriteAttribute(Attributes.classType, actualType.AssemblyQualifiedName); } }
private void WriteClassNameIfNeedBe(object value, FieldInfo field) { object fieldValue = field.GetValue(value); if (fieldValue == null) { return; } Type actualType = fieldValue.GetType(); if (!field.FieldType.Equals(actualType)) { // TODO: Examine the behavior of this // classType is not valid for cross platform usage writer.WriteAttribute(Attributes.classType, actualType.AssemblyQualifiedName); } }
public void Marshall(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(XsAttribute.AttributeType, value.GetType().AssemblyQualifiedName); writer.SetValue(value.ToString()); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.AttributeType, value.GetType().AssemblyQualifiedName); writer.SetValue(value.ToString()); }
public void WriteOn(XStreamWriter writer) { writer.WriteAttribute(name, value); }
public void ToXml(object value, XStreamWriter writer, MarshallingContext context) { writer.WriteAttribute(Attributes.Null, true.ToString()); }