Esempio n. 1
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            double dateTime = reader.ReadDouble();

            // ignore the stupid timezone
            reader.ReadUnsignedShort();

            DateTime sent = new DateTime(1970, 1, 1);

#if (FULL_BUILD || PURE_CLIENT_LIB)
            // get the offset of the time zone the server is in
            double localTimezoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(sent).TotalMilliseconds;
            // convert 1/1/1970 12AM to UTC
            sent = TimeZone.CurrentTimeZone.ToUniversalTime(sent);
#else
            double localTimezoneOffset = TimeZoneInfo.Local.GetUtcOffset(sent).TotalMilliseconds;
            sent = TimeZoneInfo.ConvertTime(sent, TimeZoneInfo.Utc);
#endif

            // bring it back to 12AM
            sent = sent.AddMilliseconds(localTimezoneOffset);

            // now that the sent object is in UTC and it represents 1/1/1970 12AM
            // convert it to the time sent by the client. The result of the operation
            // is going to be client's datetime object in UTC
            sent = sent.AddMilliseconds(dateTime);

            return(new DateType(sent));
        }
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  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. 4
0
        public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext)
        {
            double d = reader.ReadDouble();

            return(new NumberObject(d));
        }