예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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());
        }
예제 #4
0
        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());
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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 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);
        }