diff --git a/samples/HessianReader/HessianReader.csproj b/samples/HessianReader/HessianReader.csproj
index 1178b9f..5f6fbcb 100644
--- a/samples/HessianReader/HessianReader.csproj
+++ b/samples/HessianReader/HessianReader.csproj
@@ -16,4 +16,13 @@
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
diff --git a/samples/HessianReader/Program.cs b/samples/HessianReader/Program.cs
index f7518e6..ebade53 100644
--- a/samples/HessianReader/Program.cs
+++ b/samples/HessianReader/Program.cs
@@ -24,29 +24,27 @@ namespace HessianReader
Console.WriteLine("---------------------------------------------------------------");
-
-
var serializer = new DataContractHessianSerializer(typeof (RpcRequest));
using (var stream1 = new MemoryStream(myBinary))
{
- var ds = new Hessian.Deserializer(stream1);
- Hessian.ClassDef def = ds.ReadClassDefinition();
- Console.WriteLine(JsonConvert.SerializeObject(def));
- Console.WriteLine(ds.ReadValue());
- //Console.WriteLine(ds.ReadLong());
- //Console.WriteLine(ds.ReadString());
- //Console.WriteLine(ds.ReadString());
- //Console.WriteLine(ds.ReadString());
- //Console.WriteLine(ds.ReadString());
- //Console.WriteLine(ds.ReadValue());
- //Console.WriteLine(ds.ReadValue());
- Console.WriteLine(JsonConvert.SerializeObject(def));
+ var s = new Hessian.Deserializer(stream1);
+ var a = s.ReadValue();
+ Console.WriteLine(a);
+ a = s.ReadValue();
+ Console.WriteLine(a);
+ Console.WriteLine(JsonConvert.SerializeObject(a));
+ a = s.ReadValue();
+ Console.WriteLine(a);
+ Console.WriteLine(JsonConvert.SerializeObject(a));
+ a = s.ReadValue();
+ Console.WriteLine(a);
+ Console.WriteLine(JsonConvert.SerializeObject(a));
}
return;
-
+
RpcRequest req = new RpcRequest {
RequestId = "71565f61-94e8-4dcf-9760-f2fb73a6886a",
CreateMillisTime = 1547621183585,
diff --git a/src/Hessian.NET/HessianInputReader.cs b/src/Hessian.NET/HessianInputReader.cs
index 0817baf..55ff1ac 100644
--- a/src/Hessian.NET/HessianInputReader.cs
+++ b/src/Hessian.NET/HessianInputReader.cs
@@ -355,9 +355,9 @@ namespace Hessian.Net
return ReadInt32();
}
- public byte? Peek()
+ public byte ReadByte()
{
- return this.Stream.
+ return (byte)Stream.ReadByte();
}
protected void ReadLeadingByte()
diff --git a/src/Hessian.NET/HessianSerializationScheme.cs b/src/Hessian.NET/HessianSerializationScheme.cs
index 663e13d..f8caf1b 100644
--- a/src/Hessian.NET/HessianSerializationScheme.cs
+++ b/src/Hessian.NET/HessianSerializationScheme.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization;
@@ -54,12 +55,11 @@ namespace Hessian.Net
if (IsListType(info))
{
- return new ListElement(info);
+ return new ListElement(type, catalog, factory);
}
return BuildSerializationObject(type, catalog, factory);
}
-
-
+
private static ISerializationElement BuildSerializationObject(Type type, IDictionary catalog, IObjectSerializerFactory factory)
{
ISerializationElement existing;
@@ -123,7 +123,7 @@ namespace Hessian.Net
public static bool IsListType(TypeInfo typeInfo)
{
- return typeInfo.IsArray && typeInfo.HasElementType;
+ return typeof(IEnumerable).IsAssignableFrom(typeInfo);
}
}
}
\ No newline at end of file
diff --git a/src/Hessian.NET/ListElement.cs b/src/Hessian.NET/ListElement.cs
index a627392..474d75f 100644
--- a/src/Hessian.NET/ListElement.cs
+++ b/src/Hessian.NET/ListElement.cs
@@ -2,16 +2,24 @@ using System;
using System.Collections.Generic;
using System.IO;
+
namespace Hessian.Net
{
public class ListElement: ISerializationElement
{
- public ListElement(Type listType)
+ private readonly IDictionary _catalog;
+ private readonly IObjectSerializerFactory _factory;
+ public ListElement(Type listType, IDictionary catalog, IObjectSerializerFactory factory)
{
- this.ObjectType = listType.GetElementType();
+ this.ObjectType = listType;
+ this._catalog = catalog;
+ this._factory = factory;
}
-
+ private readonly Lazy listTypeResolver = new Lazy();
+
public Type ObjectType { get; }
+ public ISerializationElement ChildSerializationElement { get; }
+
public void Serialize(HessianOutputWriter writer, object graph, HessianSerializationContext context)
{
throw new NotImplementedException();
@@ -19,106 +27,112 @@ namespace Hessian.Net
public object Deserialize(HessianInputReader reader, HessianSerializationContext context)
{
+ object ret=null;
var preamble = reader.BeginList();
switch (preamble)
{
case ObjectPreamble.FixList:
+ ret =ReadFixList(reader, context);
break;
case ObjectPreamble.VarList:
+ ret = ReadVarList(reader, context);
break;
case ObjectPreamble.FixListUntyped:
+ ret = ReadFixListUntyped(reader, context);
break;
case ObjectPreamble.VarListUntyped:
+ ret = ReadVarListUntyped(reader, context);
break;
case ObjectPreamble.CompactFixList:
+ ret = ReadCompactFixList(reader, context);
break;
case ObjectPreamble.CompactFixListUntyped:
+ ret = ReadCompactFixListUntyped(reader, context);
break;
- }
-
+ }
reader.EndList();
+ return ret;
}
- private string ReadTypeName(HessianInputReader reader)
+ private string ReadTypeName(HessianInputReader reader)
{
- reader.re
- var tag = reader.Peek();
-
- if (!tag.HasValue) {
- throw new EndOfStreamException();
- }
+
+ var tag = reader.ReadByte();
+
+
// A type name is either a string, or an integer reference to a
// string already read and stored in the type-name ref map.
if ((tag >= 0x00 && tag < 0x20)
|| (tag >= 0x30 && tag < 0x34)
|| tag == 0x52
|| tag == 0x53) {
- var typeName = ReadString();
- typeNameRefs.Add(typeName);
+
+ var typeName = reader.ReadString();
return typeName;
}
- return typeNameRefs.Get(ReadInteger());
+ throw new HessianSerializerException();
+
}
#region List
- private IList