Esempio n. 1
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int  handle = reader.ReadVarInteger();
            bool inline = ((handle & 1) != 0);

            handle = handle >> 1;
            if (inline)
            {
                object[] array = new object[handle];

                ArrayType ar = new ArrayType(array);
                parseContext.addReference(ar);

                // whether vector is readonly
                int @fixed = reader.ReadVarInteger();

                if (!typeof(T).IsValueType)
                {
                    // type name of the vector's elements
                    string elementTypeName = ReaderUtils.readString(reader, parseContext);
                }

                for (int i = 0; i < handle; i++)
                {
                    if (typeof(T) == typeof(int))
                    {
                        array[i] = reader.ReadInteger();
                    }
                    else if (typeof(T) == typeof(uint))
                    {
                        array[i] = reader.ReadUInteger();
                    }
                    else if (typeof(T) == typeof(double))
                    {
                        array[i] = reader.ReadDouble();
                    }
                    else
                    {
                        array[i] = RequestParser.readData(reader, parseContext);
                        //array[ i ] = objectReader.read( reader, parseContext );
                    }
                }

                return(ar);
            }
            else
            {
                return(parseContext.getReference(handle));
            }
        }
Esempio n. 2
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int refId = reader.ReadVarInteger();

            if ((refId & 0x1) == 0)
            {
                return((DateType)parseContext.getReference(refId >> 1));
            }

            double dateTime = reader.ReadDouble();

            DateTime sent = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            try
            {
                sent = sent.AddMilliseconds(dateTime).ToLocalTime();
            }
            catch (Exception e)
            {
                if (Log.isLogging(LoggingConstants.EXCEPTION))
                {
                    Log.log(LoggingConstants.EXCEPTION, e);
                }

                sent = DateTime.MinValue;
            }

            DateType dateType = new DateType(sent);

            parseContext.addReference(dateType);
            return(dateType);
        }
Esempio n. 3
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int refId = reader.ReadVarInteger();

            if ((refId & 0x1) == 0)
            {
                return(parseContext.getReference(refId >> 1));
            }

            int           arraySize    = refId >> 1;
            IAdaptingType adaptingType = null;
            object        container    = null;

            while (true)
            {
                string str = ReaderUtils.readString(reader, parseContext);

                if (str == null || str.Length == 0)
                {
                    break;
                }

                if (container == null)
                {
                    container    = new Dictionary <object, object>();
                    adaptingType = new AnonymousObject((IDictionary)container);
                    parseContext.addReference(adaptingType);
                }

                object obj = RequestParser.readData(reader, parseContext);
                ((IDictionary)container)[str] = obj;
            }

            if (adaptingType == null)
            {
                container    = new object[arraySize];
                adaptingType = new ArrayType((object[])container);
                parseContext.addReference(adaptingType);

                for (int i = 0; i < arraySize; i++)
                {
                    ((object[])container)[i] = RequestParser.readData(reader, parseContext);
                }
            }
            else
            {
                for (int i = 0; i < arraySize; i++)
                {
                    object obj = RequestParser.readData(reader, parseContext);
                    ((IDictionary)container)[i.ToString()] = obj;
                }
            }

            return(adaptingType);
        }
Esempio n. 4
0
        public static string readString(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int len = reader.ReadVarInteger();

            if ((len & 0x1) == 0)
            {
                return((string)parseContext.getStringReference(len >> 1));
            }

            string str = reader.ReadUTF(len >> 1);

            if (str.Length == 0)
            {
                return(str);
            }

            parseContext.addStringReference(str);
            return(str);
        }
Esempio n. 5
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int refId = reader.ReadVarInteger();

            if ((refId & 0x1) == 0)
            {
                return((ArrayType)parseContext.getReference(refId >> 1));
            }

            byte[]          bytes    = reader.ReadBytes(refId >> 1);
            IAdaptingType[] objArray = new IAdaptingType[bytes.Length];

            for (int i = 0; i < bytes.Length; i++)
            {
                objArray[i] = new NumberObject(bytes[i]);
            }

            ArrayType arrayType = new ArrayType(objArray);

            parseContext.addReference(arrayType);
            return(arrayType);
        }
Esempio n. 6
0
 public Weborb.Types.IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
 {
     return(new NumberObject((reader.ReadVarInteger() << 3) >> 3));
 }
Esempio n. 7
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            int refId = reader.ReadVarInteger();

            if ((refId & 0x1) == 0)
            {
                return((IAdaptingType)parseContext.getReference(refId >> 1));
            }

            ClassInfo classInfo = getClassInfo(refId, reader, parseContext);

            Type mappedType = null;

            if (!string.IsNullOrEmpty(classInfo.className))
            {
                mappedType = Types.Types.getServerTypeForClientClass(classInfo.className);
            }

            if (classInfo.externalizable || typeof(IExternalizable).IsAssignableFrom(mappedType))
            {
                Type   type   = Types.Types.getServerTypeForClientClass(classInfo.className);
                object extobj = null;

                if (type != null)
                {
                    extobj = ObjectFactories.CreateServiceObject(type);
                }
                else
                {
                    extobj = ObjectFactories.CreateServiceObject(classInfo.className);
                }

                if (!(extobj is IExternalizable))
                {
                    throw new Exception("object must implement IExternalizable");
                }
                else
                {
                    CacheableAdaptingTypeWrapper wrapper = new CacheableAdaptingTypeWrapper();
                    parseContext.addReference(wrapper);

                    IAdaptingType returnValue = null;
                    extobj = ((IExternalizable)extobj).readExternal(reader, parseContext);

                    if (extobj is IAdaptingType)
                    {
                        returnValue = (IAdaptingType)extobj;
                    }
                    else
                    {
                        returnValue = new ConcreteObject(extobj);
                    }

                    wrapper.setType(returnValue);
                    return(returnValue);
                }
            }
            else
            {
                Dictionary <String, IAdaptingType> props = new Dictionary <String, IAdaptingType>();
                AnonymousObject anonObj     = new AnonymousObject();
                IAdaptingType   returnValue = anonObj;

                if (classInfo.className != null && classInfo.className.Length > 0)
                {
                    returnValue = new NamedObject(classInfo.className, anonObj);
                }

                parseContext.addReference(returnValue);
                int propCount = classInfo.getPropertyCount();

                for (int i = 0; i < propCount; i++)
                {
                    if (Log.isLogging(LoggingConstants.DEBUG))
                    {
                        Log.log(LoggingConstants.DEBUG, "reading object property " + classInfo.getProperty(i));
                    }

                    props[classInfo.getProperty(i)] = RequestParser.readData(reader, parseContext);
                }

                if (classInfo.looseProps)
                {
                    while (true)
                    {
                        string propName = ReaderUtils.readString(reader, parseContext);

                        if (propName == null || propName.Length == 0)
                        {
                            break;
                        }

                        props[propName] = RequestParser.readData(reader, parseContext);
                    }
                }

                anonObj.Properties = props;
                return(returnValue);
            }
        }