示例#1
0
        public void Deserialize(OSDMap map)
        {
            MessageSessions.Clear();
            PacketSessions.Clear();

            if (map.ContainsKey("FileVersion") && map["FileVersion"].AsInteger() == FileVersion)
            {
                StatisticsEnabled = map["CaptureStatistics"].AsBoolean();
                SaveSessionOnExit = map["SaveProfileOnExit"].AsBoolean();
                AutoCheckNewCaps = map["AutoCheckNewCaps"].AsBoolean();
            }
            else
            {
                Console.WriteLine("Error loading saved settings, FileVersion is null or out of date.");
                StatisticsEnabled = true;
                AutoCheckNewCaps = true;
                SaveSessionOnExit = true;
                return;
            }

            if (map.ContainsKey("message_sessions"))
            {                             
                OSDArray messageArray = (OSDArray)map["message_sessions"];

                //MessageSessions = new Dictionary<string, FilterEntryOptions>(messageArray.Count);

                for (int i = 0; i < messageArray.Count; i++)
                {
                    OSDMap sessionsMap = (OSDMap)messageArray[i];
                    FilterEntryOptions entry = new FilterEntryOptions();
                    entry.Checked = sessionsMap["Capture"].AsBoolean();
                    entry.Group = sessionsMap["Group"].AsString();
                    entry.Type = sessionsMap["Type"].AsString();
                    MessageSessions.Add(sessionsMap["Name"].AsString(), entry);                    
                }
            }

            if (map.ContainsKey("packet_sessions"))
            {
                OSDArray packetArray = (OSDArray)map["packet_sessions"];

                //PacketSessions = new Dictionary<string, FilterEntryOptions>(packetArray.Count);

                for (int i = 0; i < packetArray.Count; i++)
                {
                    OSDMap packetMap = (OSDMap)packetArray[i];
                    FilterEntryOptions entry = new FilterEntryOptions();
                    entry.Checked = packetMap["Capture"].AsBoolean();
                    entry.Group = packetMap["Group"].AsString();
                    entry.Type = packetMap["Type"].AsString();
                    PacketSessions.Add(packetMap["Name"].AsString(), entry);
                }
            }
        }
示例#2
0
        private void SaveAllSettings(string fileName)
        {
            Store.MessageSessions.Clear();
            Store.PacketSessions.Clear();

            foreach (ListViewItem item in listViewPacketFilters.Items)
            {
                FilterEntryOptions entry = new FilterEntryOptions();
                entry.Checked = item.Checked;
                entry.Type = item.SubItems[1].Text;
                entry.Group = item.Group.Name;

                if (!Store.PacketSessions.ContainsKey(item.Text))
                    Store.PacketSessions.Add(item.Text, entry);
            }

            foreach (ListViewItem item in listViewMessageFilters.Items)
            {
                FilterEntryOptions entry = new FilterEntryOptions();
                entry.Checked = item.Checked;
                entry.Type = item.SubItems[1].Text;
                entry.Group = item.Group.Name;

                if (!Store.MessageSessions.ContainsKey(item.Text))
                    Store.MessageSessions.Add(item.Text, entry);
            }

            Store.StatisticsEnabled = enableStatisticsToolStripMenuItem.Checked;
            Store.SaveSessionOnExit = saveOptionsOnExitToolStripMenuItem.Checked;
            Store.AutoCheckNewCaps = autoAddNewDiscoveredMessagesToolStripMenuItem.Checked;

            lock (m_FileIOLockerObject)
            {
                Store.SerializeToFile(fileName);
            }
        }
示例#3
0
        public void Deserialize(OSDMap map)
        {
            MessageSessions.Clear();
            PacketSessions.Clear();

            if (map.ContainsKey("FileVersion") && map["FileVersion"].AsInteger() == FileVersion)
            {
                StatisticsEnabled = map["CaptureStatistics"].AsBoolean();
                SaveSessionOnExit = map["SaveProfileOnExit"].AsBoolean();
                AutoCheckNewCaps = map["AutoCheckNewCaps"].AsBoolean();
            }
            else
            {
                Console.WriteLine("Error loading saved settings, FileVersion is null or out of date.");
                StatisticsEnabled = true;
                AutoCheckNewCaps = true;
                SaveSessionOnExit = true;
                return;
            }

            if (map.ContainsKey("message_sessions"))
            {
                OSDArray messageArray = (OSDArray)map["message_sessions"];

                //MessageSessions = new Dictionary<string, FilterEntryOptions>(messageArray.Count);

                for (int i = 0; i < messageArray.Count; i++)
                {
                    OSDMap sessionsMap = (OSDMap)messageArray[i];
                    FilterEntryOptions entry = new FilterEntryOptions();
                    entry.Checked = sessionsMap["Capture"].AsBoolean();
                    entry.Group = sessionsMap["Group"].AsString();
                    entry.Type = sessionsMap["Type"].AsString();
                    MessageSessions.Add(sessionsMap["Name"].AsString(), entry);
                }
            }

            if (map.ContainsKey("packet_sessions"))
            {
                OSDArray packetArray = (OSDArray)map["packet_sessions"];

                //PacketSessions = new Dictionary<string, FilterEntryOptions>(packetArray.Count);

                for (int i = 0; i < packetArray.Count; i++)
                {
                    OSDMap packetMap = (OSDMap)packetArray[i];
                    FilterEntryOptions entry = new FilterEntryOptions();
                    entry.Checked = packetMap["Capture"].AsBoolean();
                    entry.Group = packetMap["Group"].AsString();
                    entry.Type = packetMap["Type"].AsString();
                    PacketSessions.Add(packetMap["Name"].AsString(), entry);
                }
            }
        }