/// <summary>
        /// Serializes a specified object to binary data and writes the resulting to a stream.
        /// </summary>
        /// <param name="stream">The <see cref="System.IO.Stream" /> that is written to.</param>
        /// <param name="graph">The object that contains the data to write to the stream.</param>
        public void WriteObject(Stream stream, object graph)
        {
            if (null == stream)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var scheme = HessianSerializationScheme.CreateFromType(type);

            using (var writer = new HessianOutputWriter(stream))
            {
                var context = new HessianSerializationContext();
                scheme.Serialize(writer, graph, context);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public void Serialize(HessianOutputWriter writer, object graph, HessianSerializationContext context)
 {
     ObjectSerializer.Serialize(writer, graph);
 }
Пример #4
0
 public void Serialize(HessianOutputWriter writer, object graph, HessianSerializationContext context)
 {
     Element.Serialize(writer, graph, context);
 }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteInt32((int)graph);
 }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteInt64((long)graph);
 }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteBoolean((bool)graph);
 }
            public void Serialize(HessianOutputWriter writer, object graph)
            {
                var bytes = ((Guid)graph).ToByteArray();

                writer.WriteBytes(bytes);
            }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteDouble((double)graph);
 }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteDateTime((DateTime)graph);
 }
 public void Serialize(HessianOutputWriter writer, object graph)
 {
     writer.WriteString((string)graph);
 }