コード例 #1
0
        /// <summary>
        /// Reads the <see cref="AllianceStreamEventMessage"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="AllianceStreamEventMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public override void ReadMessage(MessageReader reader)
        {
            ThrowIfReaderNull(reader);

            var id    = reader.ReadInt32();
            var entry = StreamEntryFactory.CreateAllianceStreamEntry(id);

            entry?.ReadStreamEntry(reader);
        }
コード例 #2
0
        private static void FromMySqlDataReader(ClanSave save, DbDataReader reader)
        {
            save.ClanId = (long)reader["clan_id"];

            //save.DateCreated = (DateTime)reader["create_date"];
            //save.DateLastSave = (DateTime)reader["last_save_date"];

            save.Name             = (string)reader["name"];
            save.Description      = (string)reader["description"];
            save.ExpLevels        = (int)reader["exp_levels"];
            save.Badge            = (int)reader["badge"];
            save.InviteType       = (int)reader["invite_type"];
            save.TotalTrophies    = (int)reader["total_trophies"];
            save.RequiredTrophies = (int)reader["required_trophies"];
            save.WarsWon          = (int)reader["wars_won"];
            save.WarsLost         = (int)reader["wars_lost"];
            save.WarsTried        = (int)reader["wars_tried"];
            save.Location         = (int)reader["location"];
            save.PerkPoints       = (int)reader["perk_points"];
            save.WinStreak        = (int)reader["win_streak"];
            save.WarLogsPublic    = (bool)reader["war_logs_public"];

            var entries = (byte[])reader["entries"];
            var stream  = new MemoryStream(entries);

            using (var r = new MessageReader(stream))
            {
                var count = r.ReadInt32();
                var list  = new List <AllianceStreamEntry>(count);
                for (int i = 0; i < count; i++)
                {
                    var id    = r.ReadInt32();
                    var entry = StreamEntryFactory.CreateAllianceStreamEntry(id);

                    Debug.Assert(entry != null);

                    if (entry == null)
                    {
                        break;
                    }

                    entry.ReadStreamEntry(r);
                    list.Add(entry);
                }

                save.Entries = list;
            }
        }
コード例 #3
0
        /// <summary>
        /// Reads the <see cref="AllianceStreamMessage"/> from the specified <see cref="MessageReader"/>.
        /// </summary>
        /// <param name="reader">
        /// <see cref="MessageReader"/> that will be used to read the <see cref="AllianceStreamMessage"/>.
        /// </param>
        /// <exception cref="ArgumentNullException"><paramref name="reader"/> is null.</exception>
        public override void ReadMessage(MessageReader reader)
        {
            ThrowIfReaderNull(reader);

            Unknown1 = reader.ReadInt32();

            var count = reader.ReadInt32();

            Entries = new AllianceStreamEntry[count];
            for (int i = 0; i < count; i++)
            {
                var id    = reader.ReadInt32();
                var entry = StreamEntryFactory.CreateAllianceStreamEntry(id);
                if (entry == null)
                {
                    return;
                }

                entry.ReadStreamEntry(reader);
                Entries[i] = entry;
            }
        }