public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { var result = new JavaStackTrace(); reader.AddRef(result); foreach (var key in definition.Fields) { switch (key) { case "declaringClass": result.DeclaringClass = reader.ReadString(); break; case "methodName": result.MethodName = reader.ReadString(); break; case "fileName": result.FileName = reader.ReadString(); break; case "lineNumber": result.LineNumber = reader.ReadInt(); break; } } return(result); }
public override object ReadMap(Hessian2Reader reader) { string val = null; while (!reader.HasEnd()) { if ("name" == reader.ReadString()) { val = reader.ReadString(); } else { reader.ReadObject(); } } reader.ReadToEnd(); if (string.IsNullOrEmpty(val)) { throw new HessianException($"the value is null or empty where read enum type {Type.FullName}"); } var result = Enum.Parse(Type, val); reader.AddRef(result); return(result); }
public override object ReadMap(Hessian2Reader reader) { var result = new JavaStackTrace(); reader.AddRef(result); while (!reader.HasEnd()) { var key = reader.ReadString(); switch (key) { case "declaringClass": result.DeclaringClass = reader.ReadString(); break; case "methodName": result.MethodName = reader.ReadString(); break; case "fileName": result.FileName = reader.ReadString(); break; case "lineNumber": result.LineNumber = reader.ReadInt(); break; } } reader.ReadToEnd(); return(result); }
private T[] ReadArray <T>(Hessian2Reader reader, int length, Func <T> func) { var result = new T[length]; reader.AddRef(result); for (var i = 0; i < result.Length; i++) { result[i] = func(); } return(result); }
private T[] ReadArray(Hessian2Reader reader, int length) { var result = new T[length]; reader.AddRef(result); for (var i = 0; i < result.Length; i++) { result[i] = reader.ReadObject <T>(); } return(result); }
private IDictionary <TKey, TValue> ReadGenericDictionary <TKey, TValue>(Hessian2Reader reader) { var result = (IDictionary <TKey, TValue>)_creator(); reader.AddRef(result); while (!reader.HasEnd()) { result.Add(reader.ReadObject <TKey>(), reader.ReadObject <TValue>()); } reader.ReadToEnd(); return(result); }
private T[] ReadList(Hessian2Reader reader) { var list = new List <T>(); reader.AddRef(list); while (!reader.HasEnd()) { list.Add(reader.ReadObject <T>()); } reader.ReadToEnd(); return(list.ToArray()); }
private T[] ReadList <T>(Hessian2Reader reader, Func <T> func) { var list = new List <T>(); reader.AddRef(list); while (!reader.HasEnd()) { list.Add(func()); } reader.ReadToEnd(); return(list.ToArray()); }
public override object ReadMap(Hessian2Reader reader) { if (_genericConverter != null) { return(_genericConverter(this, reader)); } var result = (IDictionary)_creator(); reader.AddRef(result); while (!reader.HasEnd()) { result.Add(reader.ReadObject(), reader.ReadObject()); } reader.ReadToEnd(); return(result); }
public override object ReadObject(Hessian2Reader reader) { var tag = reader.ReadListStart(); switch (tag) { case Constants.Null: return(null); case Constants.VariableList: return(ReadList(reader, -1)); case Constants.VariableUnTypeList: return(ReadList(reader, -1)); case Constants.FixedList: reader.ReadType(); return(ReadList(reader, reader.ReadInt())); case Constants.FixedUnTypeList: return(ReadList(reader, reader.ReadInt())); case 0x70: case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: reader.ReadType(); return(ReadList(reader, tag - 0x70)); case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: return(ReadList(reader, tag - 0x78)); default: throw new HessianException($"unknown code {(char)tag} where read type {Type.FullName}"); } }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { var result = _creator(); reader.AddRef(result); foreach (var field in definition.Fields) { if (fieldSetters.TryGetValue(field, out var setter)) { setter.SetValue(result, reader.ReadObject(setter.FieldType)); } else { reader.ReadObject(); } } return(result); }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { var result = new JavaException(); reader.AddRef(result); string msg = null; JavaStackTrace[] traces = null; JavaException[] suppressedExceptions = null; JavaException innerException = null; foreach (var key in definition.Fields) { switch (key) { case "detailMessage": msg = reader.ReadString(); break; case "stackTrace": traces = reader.ReadObject <JavaStackTrace[]>(); break; case "suppressedExceptions": suppressedExceptions = reader.ReadObject <JavaException[]>(); break; case "cause": innerException = reader.ReadObject <JavaException>(); break; default: var info = reader.ReadObject(); if (info != result) { result.Data.Add(key, reader.ReadObject()); } break; } } result.ResumeException(definition.Type, msg, traces, suppressedExceptions, innerException == result ? null : innerException); return(result); }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { var result = _creator(); reader.AddRef(result); foreach (var propertyName in definition.Fields) { if (_propertyInfos.TryGetValue(propertyName, out var setter)) { setter(result, reader); } else { reader.ReadObject(); } } return(result); }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { string value = null; foreach (var name in definition.Fields) { if ("value" == (name)) { value = reader.ReadString(); } else { reader.ReadObject(); } } var result = convertFunc(value); reader.AddRef(result); return(result); }
public override object ReadMap(Hessian2Reader reader) { var result = _creator(); reader.AddRef(result); while (!reader.HasEnd()) { var field = reader.ReadString(); if (fieldSetters.TryGetValue(field, out var setter)) { setter.SetValue(result, reader.ReadObject(setter.FieldType)); } else { reader.ReadObject(); } } reader.ReadToEnd(); return(result); }
public override object ReadMap(Hessian2Reader reader) { var result = new JavaException(); reader.AddRef(result); string msg = null; JavaStackTrace[] traces = null; JavaException[] suppressedExceptions = null; JavaException innerException = null; while (!reader.HasEnd()) { var key = reader.ReadString(); switch (key) { case "detailMessage": msg = reader.ReadString(); break; case "stackTrace": traces = reader.ReadObject <JavaStackTrace[]>(); break; case "suppressedExceptions": suppressedExceptions = reader.ReadObject <JavaException[]>(); break; case "cause": innerException = reader.ReadObject <JavaException>(); break; default: result.Data.Add(key, reader.ReadObject()); break; } } reader.ReadToEnd(); result.ResumeException(string.Empty, msg, traces, suppressedExceptions, innerException); return(result); }
private static IEnumerable <T> Read <T>(Hessian2Reader reader, int length) { var list = new List <T>(); reader.AddRef(list); if (length >= 0) { for (var i = 0; i < length; i++) { list.Add(reader.ReadObject <T>()); } } else { while (!reader.HasEnd()) { list.Add(reader.ReadObject <T>()); } reader.ReadToEnd(); } return(list); }
public override object ReadMap(Hessian2Reader reader) { string value = null; while (!reader.HasEnd()) { var key = reader.ReadString(); if (key == "value") { value = reader.ReadString(); } else { reader.ReadObject(); } } reader.ReadToEnd(); var result = convertFunc(value); reader.AddRef(result); return(result); }
private static ICollection <TItem> ReadGenericList <T, TItem>(Hessian2Reader reader, int length) where T : ICollection <TItem>, new() { ICollection <TItem> result = new T(); reader.AddRef(result); if (length >= 0) { for (var i = 0; i < length; i++) { result.Add(reader.ReadObject <TItem>()); } } else { while (!reader.HasEnd()) { result.Add(reader.ReadObject <TItem>()); } reader.ReadToEnd(); } return(result); }
public override object ReadMap(Hessian2Reader reader) { var result = _creator(); reader.AddRef(result); while (!reader.HasEnd()) { var propertyName = reader.ReadString(); if (_propertyInfos.TryGetValue(propertyName, out var setter)) { setter(result, reader); } else { reader.ReadObject(); } } reader.ReadToEnd(); return(result); }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { if (Type.IsGenericType) { var dic = (IDictionary <string, object>)_creator(); reader.AddRef(dic); foreach (var field in definition.Fields) { dic.Add(field, reader.ReadObject()); } dic.Add("$Type", definition.Type); return(dic); } var hashTable = (IDictionary)_creator(); reader.AddRef(hashTable); foreach (var field in definition.Fields) { hashTable.Add(field, reader.ReadObject()); } hashTable.Add("$Type", definition.Type); return(hashTable); }
private ICollection ReadObjectList(Hessian2Reader reader, int length) { var result = new ArrayList(); reader.AddRef(result); if (length >= 0) { for (var i = 0; i < length; i++) { result.Add(reader.ReadObject()); } } else { while (!reader.HasEnd()) { result.Add(reader.ReadObject()); } reader.ReadToEnd(); } return(result); }
public override object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { string val = null; foreach (var name in definition.Fields) { if ("name" == name) { val = reader.ReadString(); } else { reader.ReadObject(); } } if (string.IsNullOrEmpty(val)) { throw new HessianException($"the value is null or empty where read enum type {Type.FullName}"); } var result = Enum.Parse(Type, val); reader.AddRef(result); return(result); }
public override object ReadList(Hessian2Reader reader, int length) { return(length >= 0 ? ReadArray(reader, length) : ReadList(reader)); }
public override object ReadList(Hessian2Reader reader, int length) { return(((IEnumerable)base.ReadList(reader, length)).GetEnumerator()); }
public override object ReadObject(Hessian2Reader reader) { var result = base.ReadObject(reader); return(((IEnumerable)result)?.GetEnumerator()); }
public virtual object ReadObject(Hessian2Reader reader, ObjectDefinition definition) { throw new NotSupportedException(); }
public virtual object ReadMap(Hessian2Reader reader) { throw new NotSupportedException(); }
public virtual object ReadList(Hessian2Reader reader, int length) { throw new NotSupportedException(); }
public override object ReadList(Hessian2Reader reader, int length) { return(_converter(reader, length)); }