示例#1
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.TargetType = (TargetType)reader.ReadByte();

            ushort numTargets = reader.ReadUInt16();

            int[] targets = new int[numTargets];
            for (int i = 0; i < targets.Length; ++i)
            {
                targets[i] = reader.ReadInt32();
            }

            TargetIds = targets;

            Sequence = reader.ReadInt32();
            SourceId = reader.ReadInt32();

            byte frames = reader.ReadByte();

            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
            {
                Data[i] = reader.ReadBytes();
            }
        }
示例#2
0
 public virtual void Deserialize(ISerializationContext context, IValueReader reader)
 {
     WaveEncoding  = (WaveFormatEncoding)reader.ReadUInt32();
     Channels      = reader.ReadByte();
     BitsPerSample = reader.ReadByte();
     SampleRate    = reader.ReadInt32();
 }
示例#3
0
            public void Deserialize(IValueReader reader)
            {
                int count = reader.ReadByte("Count");

                for (var i = 0; i < count; i++)
                {
                    int propIndex = reader.ReadByte("PropertyIndex" + i);
                    _propertySyncs[propIndex].ReadValue(this, reader);
                }
            }
        public void ReadWriteByte()
        {
            IValueWriter writer = GetWriter();

            writer.WriteByte(Byte.MaxValue);
            writer.WriteByte(128);
            writer.WriteByte(Byte.MinValue);
            writer.Flush();

            IValueReader reader = GetReader(writer);

            Assert.AreEqual(Byte.MaxValue, reader.ReadByte());
            Assert.AreEqual(128, reader.ReadByte());
            Assert.AreEqual(Byte.MinValue, reader.ReadByte());
        }
示例#5
0
 public override void Deserialize(ISerializationContext context, IValueReader reader)
 {
     base.Deserialize(context, reader);
     Bitrate    = reader.ReadInt32();
     FrameSize  = reader.ReadInt16();
     Complexity = reader.ReadByte();
 }
示例#6
0
 public void Deserialize(ISerializationContext context, IValueReader reader)
 {
     Identity = reader.ReadString();
     Nickname = reader.ReadString();
     Avatar   = reader.ReadString();
     Status   = (Status)reader.ReadByte();
 }
        public override void ReadPayload(IValueReader reader)
        {
            this.NetworkID = reader.ReadUInt32();
            this.CharacterName = reader.ReadString();

            this.Action = (PlayerUpdateAction)reader.ReadByte();
        }
        /// <summary>
        /// Reads a <see cref="GuildMemberNameRank"/> from a <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the <see cref="GuildMemberNameRank"/> from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>The <see cref="GuildMemberNameRank"/> read from the <paramref name="reader"/>.</returns>
        public static GuildMemberNameRank ReadGuildMemberNameRank(this IValueReader reader, string name)
        {
            string    memberName;
            GuildRank rank;

            if (reader.SupportsNameLookup)
            {
                if (reader.SupportsNodes)
                {
                    var r = reader.ReadNode(name);
                    memberName = r.ReadString(_nameValueKey);
                    rank       = r.ReadByte(_rankValueKey);
                }
                else
                {
                    var s             = reader.ReadString(name);
                    var lastDelimiter = s.LastIndexOf(_concatDelimiter);
                    memberName = s.Substring(0, lastDelimiter);
                    var sRank = s.Substring(lastDelimiter + 1);
                    rank = byte.Parse(sRank);
                }
            }
            else
            {
                memberName = reader.ReadString(null);
                rank       = reader.ReadByte(null);
            }

            return(new GuildMemberNameRank(memberName, rank));
        }
示例#9
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     ChangeAction = (NotifyCollectionChangedAction)reader.ReadByte();
     if (ChangeAction != NotifyCollectionChangedAction.Reset)
     {
         People = reader.ReadEnumerable(context, (c, r) => new Person(c, r));
     }
 }
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Type = (GroupCommunicationType)reader.ReadByte();
     if (Type == GroupCommunicationType.Host)
     {
         Host = new Target(context, reader);
     }
 }
示例#11
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Reason = (ConnectionResult)reader.ReadByte();
     if (Reason == ConnectionResult.Custom)
     {
         CustomReason = reader.ReadString();
     }
 }
示例#12
0
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot  = r.ReadByte("Slot");
                var type  = r.ReadEnum <QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return(new QuickBarSlotValues(slot, type, value));
            }
示例#13
0
 public void Deserialize(ISerializationContext context, IValueReader reader)
 {
     UserId           = reader.ReadInt32();
     Username         = reader.ReadString();
     CurrentChannelId = reader.ReadInt32();
     Nickname         = reader.ReadString();
     Phonetic         = reader.ReadString();
     IsMuted          = reader.ReadBool();
     Status           = (UserStatus)reader.ReadByte();
     Comment          = reader.ReadString();
 }
示例#14
0
        public void Deserialize(ISerializationContext context, IValueReader reader)
        {
            Name             = reader.ReadString();
            Description      = reader.ReadString();
            Logo             = reader.ReadString();
            Passworded       = reader.ReadBool();
            RegistrationMode = (UserRegistrationMode)reader.ReadByte();

            if (RegistrationMode != UserRegistrationMode.None)
            {
                RegistrationContent = reader.ReadString();
            }
        }
示例#15
0
        /// <summary>
        /// Reads a Color.
        /// </summary>
        /// <param name="reader">IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>Value read from the reader.</returns>
        public static Color ReadColor(this IValueReader reader, string name)
        {
            byte r, g, b, a;

            if (reader.SupportsNameLookup)
            {
                var value = reader.ReadString(name);
                var split = value.Split(',');
                r = Parser.Invariant.ParseByte(split[0]);
                g = Parser.Invariant.ParseByte(split[1]);
                b = Parser.Invariant.ParseByte(split[2]);
                a = Parser.Invariant.ParseByte(split[3]);
            }
            else
            {
                r = reader.ReadByte(null);
                g = reader.ReadByte(null);
                b = reader.ReadByte(null);
                a = reader.ReadByte(null);
            }

            return(new Color(r, g, b, a));
        }
示例#16
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            SourceId = reader.ReadInt32();
            Sequence = reader.ReadInt32();

            byte frames = reader.ReadByte();

            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
            {
                Data[i] = reader.ReadBytes();
            }
        }
示例#17
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.SourceName   = reader.ReadString();
            this.SourceResult = (SourceResult)reader.ReadByte();

            switch (this.SourceResult)
            {
            case Messages.SourceResult.NewSource:
            case Messages.SourceResult.SourceRemoved:
            case Messages.SourceResult.Succeeded:
                this.Source = new AudioSource(context, reader);
                break;
            }
        }
示例#18
0
        /// <summary>
        /// Reads the values for this <see cref="NPCChatConditionalCollectionBase"/> from an <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader"><see cref="IValueReader"/> to read the values from.</param>
        /// <exception cref="InvalidEnumArgumentException">The read <see cref="NPCChatConditionalEvaluationType"/>
        /// was not a defined value of the <see cref="NPCChatConditionalEvaluationType"/> enum.</exception>
        public void Read(IValueReader reader)
        {
            var evaluationTypeValue = reader.ReadByte("EvaluationType");
            var items = reader.ReadManyNodes("Items", CreateItem);

            var evaluationType = (NPCChatConditionalEvaluationType)evaluationTypeValue;

            if (!EnumHelper <NPCChatConditionalEvaluationType> .IsDefined(evaluationType))
            {
                const string errmsg = "Invalid NPCChatConditionalEvaluationType `{0}`.";
                throw new InvalidEnumArgumentException(string.Format(errmsg, evaluationTypeValue));
            }

            SetReadValues(evaluationType, items);
        }
示例#19
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            PersistableHelper.Read(this, reader);

            // Equipped bodies

            int count = reader.ReadByte("EquippedBodiesCount");
            _equippedBodies.Clear();

            for (var i = 0; i < count; i++)
            {
                var s = reader.ReadString("EquippedBody_" + i);
                _equippedBodies.Add(s);
            }
        }
        public static int Read7BitEncodedInt(this IValueReader reader)
        {
            int  count = 0;
            int  shift = 0;
            byte b;

            do
            {
                b = reader.ReadByte();

                count |= (b & 127) << shift;
                shift += 7;
            } while ((b & 128) != 0);

            return(count);
        }
示例#21
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        public void ReadState(IValueReader reader)
        {
            PersistableHelper.Read(this, reader);

            // Equipped bodies

            int count = reader.ReadByte("EquippedBodiesCount");

            _equippedBodies.Clear();

            for (var i = 0; i < count; i++)
            {
                var s = reader.ReadString("EquippedBody_" + i);
                _equippedBodies.Add(s);
            }
        }
示例#22
0
        /// <summary>
        /// Reads a <see cref="NPCChatConditionalParameter"/> from the given <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the <see cref="NPCChatConditionalParameter"/> from.</param>
        /// <returns>The <see cref="NPCChatConditionalParameter"/> read from the <see cref="IValueReader"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">The read <see cref="NPCChatConditionalParameterType"/> is not a
        /// defined value of the <see cref="NPCChatConditionalParameterType"/> enum.</exception>
        public static NPCChatConditionalParameter Read(IValueReader reader)
        {
            var valueTypeValue = reader.ReadByte("ValueType");
            var valueType      = (NPCChatConditionalParameterType)valueTypeValue;

            if (!EnumHelper <NPCChatConditionalParameterType> .IsDefined(valueType))
            {
                const string errmsg = "Invalid NPCChatConditionalParameterType `{0}`.";
                throw new InvalidEnumArgumentException(string.Format(errmsg, valueType));
            }

            // Create the parameter and read the value
            var parameter = CreateParameter(valueType);

            parameter.ReadValue(reader, "Value");

            return(parameter);
        }
示例#23
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.Result = (GenericResult)reader.ReadByte();
            if (this.Result != GenericResult.Success)
            {
                return;
            }

            DefaultChannelId = reader.ReadInt32();

            int nchannels = reader.ReadInt32();

            this.channels = new List <ChannelInfo> (nchannels);
            for (int i = 0; i < nchannels; ++i)
            {
                this.channels.Add(new ChannelInfo(context, reader));
            }
        }
        /// <summary>
        /// Reads the values for this NPCChatResponseBase from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read the values from.</param>
        protected void Read(IValueReader reader)
        {
            var value       = reader.ReadByte("Value");
            var page        = reader.ReadNPCChatDialogItemID("Page");
            var text        = reader.ReadString("Text");
            var actionNames = reader.ReadMany("Actions", ((r, name) => r.ReadString(name)));
            var actions     = GetActionsFromNames(actionNames);

            var cReader         = reader.ReadNode("Conditionals");
            var hasConditionals = cReader.ReadBool("HasConditionals");
            NPCChatConditionalCollectionBase conditionals = null;

            if (hasConditionals)
            {
                conditionals = CreateConditionalCollection();
                if (conditionals != null)
                {
                    conditionals.Read(cReader);
                }
            }

            SetReadValues(value, page, text, conditionals, actions);
        }
示例#25
0
        /// <summary>
        /// Reads a <see cref="NPCChatConditionalParameter"/> from the given <see cref="IValueReader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the <see cref="NPCChatConditionalParameter"/> from.</param>
        /// <returns>The <see cref="NPCChatConditionalParameter"/> read from the <see cref="IValueReader"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">The read <see cref="NPCChatConditionalParameterType"/> is not a
        /// defined value of the <see cref="NPCChatConditionalParameterType"/> enum.</exception>
        public static NPCChatConditionalParameter Read(IValueReader reader)
        {
            var valueTypeValue = reader.ReadByte("ValueType");
            var valueType = (NPCChatConditionalParameterType)valueTypeValue;

            if (!EnumHelper<NPCChatConditionalParameterType>.IsDefined(valueType))
            {
                const string errmsg = "Invalid NPCChatConditionalParameterType `{0}`.";
                throw new InvalidEnumArgumentException(string.Format(errmsg, valueType));
            }

            // Create the parameter and read the value
            var parameter = CreateParameter(valueType);
            parameter.ReadValue(reader, "Value");

            return parameter;
        }
示例#26
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            SourceId = reader.ReadInt32 ();
            Sequence = reader.ReadInt32();

            byte frames = reader.ReadByte();
            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
                Data[i] = reader.ReadBytes();
        }
示例#27
0
        /// <summary>
        /// Reads an AllianceID from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read from.</param>
        /// <param name="name">Unique name of the value to read.</param>
        /// <returns>The AllianceID read from the IValueReader.</returns>
        public static AllianceID Read(IValueReader reader, string name)
        {
            var value = reader.ReadByte(name);

            return(new AllianceID(value));
        }
示例#28
0
            /// <summary>
            /// Reads a <see cref="QuickBarSlotValues"/> from an <see cref="IValueReader"/>.
            /// </summary>
            /// <param name="r">The <see cref="IValueReader"/> to read the values from.</param>
            /// <returns>The <see cref="QuickBarSlotValues"/> read from the <paramref name="r"/>.</returns>
            public static QuickBarSlotValues Read(IValueReader r)
            {
                var slot = r.ReadByte("Slot");
                var type = r.ReadEnum<QuickBarItemType>("Type");
                var value = r.ReadInt("Value");

                return new QuickBarSlotValues(slot, type, value);
            }
示例#29
0
		public override void ReadPayload (ISerializationContext context, IValueReader reader)
		{
			ChangeAction = (NotifyCollectionChangedAction)reader.ReadByte();
			if (ChangeAction != NotifyCollectionChangedAction.Reset)
				People = reader.ReadEnumerable (context, (c, r) => new Person (c, r));
		}
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.Reason = (ConnectionRejectedReason)reader.ReadByte();
 }
示例#31
0
 public void Deserialize(ISerializationContext context, IValueReader reader)
 {
     this.UserId = reader.ReadInt32();
     this.ResultState = (LoginResultState)reader.ReadByte ();
 }
示例#32
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.TargetType = (TargetType)reader.ReadByte();

            ushort numTargets = reader.ReadUInt16();
            int[] targets = new int[numTargets];
            for (int i = 0; i < targets.Length; ++i)
                targets[i] = reader.ReadInt32();

            TargetIds = targets;

            Sequence = reader.ReadInt32();
            SourceId = reader.ReadInt32();

            byte frames = reader.ReadByte();
            Data = new byte[frames][];

            for (int i = 0; i < frames; ++i)
                Data[i] = reader.ReadBytes();
        }
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.Reason = (ConnectionRejectedReason)reader.ReadByte ();
 }
示例#34
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.Result = (GenericResult)reader.ReadByte();
            if (this.Result != GenericResult.Success)
                return;

            DefaultChannelId = reader.ReadInt32();

            int nchannels = reader.ReadInt32();
            this.channels = new List<ChannelInfo> (nchannels);
            for (int i = 0; i < nchannels; ++i)
                this.channels.Add (new ChannelInfo (context, reader));
        }
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     GroupId  = reader.ReadInt32();
     Response = (InvitationResponse)reader.ReadByte();
 }
示例#36
0
        public override void ReadPayload(ISerializationContext context, IValueReader reader)
        {
            this.SourceName = reader.ReadString ();
            this.SourceResult = (SourceResult)reader.ReadByte ();

            switch (this.SourceResult)
            {
                case Messages.SourceResult.NewSource:
                case Messages.SourceResult.SourceRemoved:
                case Messages.SourceResult.Succeeded:
                    this.Source = new AudioSource (context, reader);
                    break;
            }
        }
示例#37
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Status = (PunchThroughStatus)reader.ReadByte();
 }
示例#38
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Result = (ConnectResult)reader.ReadByte();
     KeyboardEncryption = reader.ReadBool();
     MouseEncryption = reader.ReadBool();
 }
		public override void ReadPayload (ISerializationContext context, IValueReader reader)
		{
			GroupId = reader.ReadInt32();
			Response = (InvitationResponse)reader.ReadByte();
		}
示例#40
0
        /// <summary>
        /// Reads the values for this NPCChatResponseBase from an IValueReader.
        /// </summary>
        /// <param name="reader">IValueReader to read the values from.</param>
        protected void Read(IValueReader reader)
        {
            var value = reader.ReadByte("Value");
            var page = reader.ReadNPCChatDialogItemID("Page");
            var text = reader.ReadString("Text");
            var actionNames = reader.ReadMany("Actions", ((r, name) => r.ReadString(name)));
            var actions = GetActionsFromNames(actionNames);

            var cReader = reader.ReadNode("Conditionals");
            var hasConditionals = cReader.ReadBool("HasConditionals");
            NPCChatConditionalCollectionBase conditionals = null;
            if (hasConditionals)
            {
                conditionals = CreateConditionalCollection();
                if (conditionals != null)
                    conditionals.Read(cReader);
            }

            SetReadValues(value, page, text, conditionals, actions);
        }
示例#41
0
 // It's important to ensure that writes and reads occur in the same order.
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Nickname = reader.ReadString();
     NewState = (UserState)reader.ReadByte();
 }
示例#42
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Reason = (ConnectionResult)reader.ReadByte();
     if (Reason == ConnectionResult.Custom)
         CustomReason = reader.ReadString();
 }
示例#43
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Mode = (UserListMode) reader.ReadByte();
 }
示例#44
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.ChannelId = reader.ReadInt32();
     this.Result    = (ChannelEditResult)reader.ReadByte();
 }
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.Result = (ChannelChangeResult)reader.ReadByte ();
     this.MoveInfo = new ChannelChangeInfo (context, reader);
 }
 public static ShopItemIndex ReadShopItemIndex(this IValueReader reader, string name)
 {
     return(new ShopItemIndex(reader.ReadByte(name)));
 }
示例#47
0
 // It's important to ensure that writes and reads occur in the same order.
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Nickname = reader.ReadString();
     NewState = (UserState)reader.ReadByte();
 }
 public override void ReadPayload(IValueReader reader)
 {
     this.Reason = (ConnectionRejectedReason)reader.ReadByte ();
 }
示例#49
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Status = (PunchThroughStatus)reader.ReadByte();
 }
示例#50
0
        public void Deserialize(ISerializationContext context, IValueReader reader)
        {
            Name = reader.ReadString();
            Description = reader.ReadString();
            Logo = reader.ReadString();
            Passworded = reader.ReadBool();
            RegistrationMode = (UserRegistrationMode)reader.ReadByte();

            if (RegistrationMode != UserRegistrationMode.None)
                RegistrationContent = reader.ReadString();
        }
示例#51
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     Result = (RegisterResult)reader.ReadByte();
 }
示例#52
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     OriginalMessageId = reader.ReadUInt16();
     Count = reader.ReadByte();
     Payload = reader.ReadBytes();
 }
示例#53
0
 public byte ReadValue(IValueReader valueReader)
 {
     return(valueReader.ReadByte());
 }
		public override void ReadPayload (ISerializationContext context, IValueReader reader)
		{
			Type = (GroupCommunicationType)reader.ReadByte();
			if (Type == GroupCommunicationType.Host)
				Host = new Target (context, reader);
		}
示例#55
0
 public void Deserialize(ISerializationContext context, IValueReader reader)
 {
     UserId = reader.ReadInt32();
     Username = reader.ReadString();
     CurrentChannelId = reader.ReadInt32();
     Nickname = reader.ReadString();
     Phonetic = reader.ReadString();
     IsMuted = reader.ReadBool();
     Status = (UserStatus)reader.ReadByte();
     Comment = reader.ReadString();
 }
示例#56
0
            public void Deserialize(IValueReader reader)
            {
                int count = reader.ReadByte("Count");

                for (var i = 0; i < count; i++)
                {
                    int propIndex = reader.ReadByte("PropertyIndex" + i);
                    _propertySyncs[propIndex].ReadValue(this, reader);
                }
            }
示例#57
0
 internal void Deserialize(IValueReader reader)
 {
     this.UserId = reader.ReadInt32();
     this.ResultState = (LoginResultState)reader.ReadByte ();
 }
示例#58
0
 public override void ReadPayload(ISerializationContext context, IValueReader reader)
 {
     this.ChannelId = reader.ReadInt32();
     this.Result = (ChannelEditResult)reader.ReadByte();
 }