Ejemplo n.º 1
0
        private void CopyStats(Dictionary <string, NetworkStat> from, List <Tuple <string, NetworkStat> > to)
        {
            try
            {
                foreach (var stat in from)
                {
                    m_helper.Add(stat.Key, stat.Value);
                }

                foreach (var item in to) // Copy existing stats
                {
                    NetworkStat stat;
                    if (m_helper.TryGetValue(item.Item1, out stat))
                    {
                        m_helper.Remove(item.Item1);
                        item.Item2.MessageCount       = stat.MessageCount;
                        item.Item2.TotalSize          = stat.TotalSize;
                        item.Item2.UniqueMessageCount = stat.UniqueMessageCount;
                        item.Item2.IsReliable         = stat.IsReliable;
                        stat.Clear();
                    }
                }

                foreach (var stat in m_helper) // Copy newly added stats
                {
                    NetworkStat myStat = new NetworkStat();
                    to.Add(new Tuple <string, NetworkStat>(stat.Key, myStat));
                    myStat.MessageCount       = stat.Value.MessageCount;
                    myStat.TotalSize          = stat.Value.TotalSize;
                    myStat.UniqueMessageCount = stat.Value.UniqueMessageCount;
                    myStat.IsReliable         = stat.Value.IsReliable;
                    stat.Value.Clear();
                }
            }
            finally
            {
                m_helper.Clear();
            }
        }
        private void CopyStats(Dictionary<string, NetworkStat> from, List<Tuple<string, NetworkStat>> to)
        {
            try
            {
                foreach (var stat in from)
                {
                    m_helper.Add(stat.Key, stat.Value);
                }

                foreach (var item in to) // Copy existing stats
                {
                    NetworkStat stat;
                    if (m_helper.TryGetValue(item.Item1, out stat))
                    {
                        m_helper.Remove(item.Item1);
                        item.Item2.MessageCount = stat.MessageCount;
                        item.Item2.TotalSize = stat.TotalSize;
                        item.Item2.UniqueMessageCount = stat.UniqueMessageCount;
                        item.Item2.IsReliable = stat.IsReliable;
                        stat.Clear();
                    }
                }

                foreach (var stat in m_helper) // Copy newly added stats
                {
                    NetworkStat myStat = new NetworkStat();
                    to.Add(new Tuple<string, NetworkStat>(stat.Key, myStat));
                    myStat.MessageCount = stat.Value.MessageCount;
                    myStat.TotalSize = stat.Value.TotalSize;
                    myStat.UniqueMessageCount = stat.Value.UniqueMessageCount;
                    myStat.IsReliable = stat.Value.IsReliable;
                    stat.Value.Clear();
                }
            }
            finally
            {
                m_helper.Clear();
            }
        }