Esempio n. 1
0
 public void AddToAllFriends(FriendTemplate template)
 {
     if (!_allFriends.ContainsKey(template.Id))
     {
         _allFriends.Add(template.Id, template);
     }
 }
Esempio n. 2
0
        private Dictionary <uint, FriendTemplate> _allFriends; // temp id, template

        public void Load()
        {
            _allFriends = new Dictionary <uint, FriendTemplate>();

            _log.Info("Loading friends ...");
            using (var connection = MySQL.CreateConnection())
            {
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM friends";
                    command.Prepare();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var template = new FriendTemplate()
                            {
                                Id       = reader.GetUInt32("id"),
                                FriendId = reader.GetUInt32("friend_id"),
                                Owner    = reader.GetUInt32("owner")
                            };
                            _allFriends.Add(template.Id, template);
                        }
                    }
                }
            }

            _log.Info("Loaded {0} friends", _allFriends.Count);
        }