コード例 #1
0
        IMyCatValue IMyCatValue.ReadValue(MyCatPacket packet, long length, bool nullVal)
        {
            if (nullVal)
            {
                return(new MyCatTimeSpan(true));
            }

            if (length >= 0)
            {
                string value = packet.ReadString(length);
                ParseMyCat(value);
                return(this);
            }

            long bufLength = packet.ReadByte();
            int  negate    = 0;

            if (bufLength > 0)
            {
                negate = packet.ReadByte();
            }

            isNull = false;
            if (bufLength == 0)
            {
                isNull = true;
            }
            else if (bufLength == 5)
            {
                mValue = new TimeSpan(packet.ReadInteger(4), 0, 0, 0);
            }
            else if (bufLength == 8)
            {
                mValue = new TimeSpan(packet.ReadInteger(4),
                                      packet.ReadByte(), packet.ReadByte(), packet.ReadByte());
            }
            else
            {
                mValue = new TimeSpan(packet.ReadInteger(4),
                                      packet.ReadByte(), packet.ReadByte(), packet.ReadByte(),
                                      packet.ReadInteger(4) / 1000000);
            }

            if (negate == 1)
            {
                mValue = mValue.Negate();
            }
            return(this);
        }
コード例 #2
0
        private void HandleAuthChange(MyCatPacket packet)
        {
            byte b = packet.ReadByte();

            Debug.Assert(b == 0xfe);

            string method = packet.ReadString();

            byte[] authData = new byte[packet.Length - packet.Position];
            Array.Copy(packet.Buffer, packet.Position, authData, 0, authData.Length);

            MyCatAuthenticationPlugin plugin = MyCatAuthenticationPlugin.GetPlugin(method, driver, authData);

            plugin.AuthenticationChange();
        }
コード例 #3
0
        IMyCatValue IMyCatValue.ReadValue(MyCatPacket packet, long length, bool nullVal)
        {
            if (nullVal)
            {
                return(new MyCatUByte(true));
            }

            if (length == -1)
            {
                return(new MyCatUByte((byte)packet.ReadByte()));
            }
            else
            {
                return(new MyCatUByte(Byte.Parse(packet.ReadString(length))));
            }
        }
コード例 #4
0
        IMyCatValue IMyCatValue.ReadValue(MyCatPacket packet, long length, bool nullVal)
        {
            if (nullVal)
            {
                return(new MyCatByte(true));
            }

            if (length == -1)
            {
                return(new MyCatByte((sbyte)packet.ReadByte()));
            }
            else
            {
                string    s = packet.ReadString(length);
                MyCatByte b = new MyCatByte(SByte.Parse(s, NumberStyles.Any, CultureInfo.InvariantCulture));
                b.TreatAsBoolean = TreatAsBoolean;
                return(b);
            }
        }
コード例 #5
0
        IMyCatValue IMyCatValue.ReadValue(MyCatPacket packet, long length, bool nullVal)
        {
            if (nullVal)
            {
                return(new MyCatDateTime(type, true));
            }

            if (length >= 0)
            {
                string value = packet.ReadString(length);
                return(ParseMyCat(value));
            }

            long bufLength = packet.ReadByte();
            int  year = 0, month = 0, day = 0;
            int  hour = 0, minute = 0, second = 0, microsecond = 0;

            if (bufLength >= 4)
            {
                year  = packet.ReadInteger(2);
                month = packet.ReadByte();
                day   = packet.ReadByte();
            }

            if (bufLength > 4)
            {
                hour   = packet.ReadByte();
                minute = packet.ReadByte();
                second = packet.ReadByte();
            }

            if (bufLength > 7)
            {
                microsecond = packet.Read3ByteInt();
                packet.ReadByte();
            }

            return(new MyCatDateTime(type, year, month, day, hour, minute, second, microsecond));
        }
コード例 #6
0
        void IMyCatValue.SkipValue(MyCatPacket packet)
        {
            int len = packet.ReadByte();

            packet.Position += len;
        }
コード例 #7
0
 void IMyCatValue.SkipValue(MyCatPacket packet)
 {
     packet.ReadByte();
 }