Example #1
0
        public static Result ReadResult(this ObjectReader reader, int index)
        {
            var status           = reader.ReadInt32();
            var exceptionMessage = reader.ReadStringOrReference();

            var value = new Result();

            reader.ReferenceContainer[index] = value;
            value._Status  = status;
            value._Message = exceptionMessage;
            return(value);
        }
Example #2
0
        public static Result ReadGResult(this ObjectReader reader, int index)
        {
            var status           = reader.ReadInt32();
            var exceptionMessage = reader.ReadStringOrReference();
            var elementType      = reader.ReadType();

            var value = Activator.CreateInstance(DefineTypes.GResult.MakeGenericType(elementType)) as Result;

            reader.ReferenceContainer[index] = value;
            value._Status  = status;
            value._Message = exceptionMessage;
            var resultValue = reader.Deserialize();

            value.SetValue(resultValue);

            return(value);
        }
Example #3
0
        public static StringBuilder[] ReadStringBuilderArray(this ObjectReader reader)
        {
            var length = reader.ReadInt32();

            StringBuilder[] value = new StringBuilder[length];
            for (int i = 0; i < length; i++)
            {
                var str = reader.ReadStringOrReference();
                if (str == null)
                {
                    value[i] = null;
                }
                else
                {
                    value[i] = new StringBuilder(str);
                }
            }
            return(value);
        }
Example #4
0
        public static Type ReadType(this ObjectReader reader)
        {
            var  simplifyQualifiedName = reader.ReadStringOrReference();
            Type type;

            if (!TypeCache.TryGetValue(simplifyQualifiedName, out type))
            {
                lock (TypeCache)
                    if (!TypeCache.TryGetValue(simplifyQualifiedName, out type))
                    {
                        type = SerializationHelper.RecoveryQualifiedName(simplifyQualifiedName);
                        if (type == null)
                        {
                            throw new ArgumentException("无法找到简化限定符的类型 " + simplifyQualifiedName);
                        }
                        TypeCache.Add(simplifyQualifiedName, type);
                    }
            }
            return(type);
        }
Example #5
0
        public static StringBuilder ReadStringBuilder(this ObjectReader reader)
        {
            var str = reader.ReadStringOrReference();

            return(new StringBuilder(str));
        }