public void Serialize(HessianOutputWriter writer, object graph, HessianSerializationContext context) { var index = context.Instances.IndexOf(graph); if (index > -1) { writer.WriteInstanceReference(index); return; } context.Instances.Add(graph); index = context.Classes.IndexOf(ObjectType); if (index < 0) { writer.BeginClassDefinition(); writer.WriteString(ClassName); writer.WriteInt32(ObjectProperties.Count); foreach (var property in ObjectProperties) { writer.WriteString(property.PropertyName); } writer.EndClassDefinition(); index = context.Classes.Count; context.Classes.Add(ObjectType); } writer.WriteObjectReference(index); foreach (var item in ObjectProperties) { var value = item.Property.GetValue(graph); item.Serialize(writer, value, context); } }
public void Serialize(HessianOutputWriter writer, object graph) { writer.WriteInt32((int)graph); }