Commits

Mathias Kluba committed 167a6d4

fix for arrays

  • Participants
  • Parent commits 1914fff

Comments (0)

Files changed (1)

File SOS.Net/FormMain.cs

             this.tabControlMain.SelectTab(this.tabPageProcesses);
 
             var result = this.controller.RefreshProcesses();
-            if(!string.IsNullOrEmpty(this.textBoxSearchProcesses.Text))
+            if (!string.IsNullOrEmpty(this.textBoxSearchProcesses.Text))
                 result = this.controller.FilterProcesses(this.textBoxSearchProcesses.Text);
 
 
             this.listViewProcesses.BeginUpdate();
             this.listViewProcesses.Items.Clear();
             this.listViewProcesses.Items.AddRange(this.controller.FilterProcesses(this.textBoxSearchProcesses.Text));
-            this.listViewProcesses.EndUpdate();            
+            this.listViewProcesses.EndUpdate();
         }
 
         private void toolStripButtonAttach_Click(object sender, EventArgs e)
 
         private void AttachSelectedProcess()
         {
-            if(this.listViewProcesses.SelectedIndices != null && this.listViewProcesses.SelectedIndices.Count > 0)
+            if (this.listViewProcesses.SelectedIndices != null && this.listViewProcesses.SelectedIndices.Count > 0)
             {
                 var selected = this.listViewProcesses.Items[this.listViewProcesses.SelectedIndices[0]];
                 this.controller.AttachToProcess(selected.SubItems[0].Text);
                 this.typesToolStripMenuItem.Enabled = true;
                 this.toolStripButtonDump.Enabled = true;
             }
-            
+
             this.RefreshAppDomains();
         }
 
         }
 
         private void textBoxCdbInput_KeyDown(object sender, KeyEventArgs e)
-        {            
-            if(e.KeyValue == 13)
+        {
+            if (e.KeyValue == 13)
             {
                 // RETURN
                 this.controller.ExecuteCommand(this.textBoxCdbInput.Text);
                 e.Handled = true;
                 e.SuppressKeyPress = true;
             }
-            else if(e.KeyValue == 38)
+            else if (e.KeyValue == 38)
             {
                 // UP
                 this.textBoxCdbInput.Text = this.controller.GetNextCommand();
                 e.Handled = true;
                 e.SuppressKeyPress = true;
             }
-            else if(e.KeyValue == 40)
+            else if (e.KeyValue == 40)
             {
                 // DOWN
                 this.textBoxCdbInput.Text = this.controller.GetPreviousCommand();
 
         private void RefreshAppDomains()
         {
-            System.Diagnostics.Debug.Assert(controller.Attached,"can't refresh appdomains if not attached"); // occurs when clicking refresh on the app domain tab without attaching a process up front
+            System.Diagnostics.Debug.Assert(controller.Attached, "can't refresh appdomains if not attached"); // occurs when clicking refresh on the app domain tab without attaching a process up front
             this.tabControlMain.SelectTab(this.tabPageAppDomain);
 
             this.listViewAppDomains.BeginUpdate();
             if (this.listViewAppDomains.SelectedIndices != null && this.listViewAppDomains.SelectedIndices.Count > 0)
             {
                 var selected = this.listViewAppDomains.Items[this.listViewAppDomains.SelectedIndices[0]];
-                
+
                 this.listViewAssemblies.BeginUpdate();
                 this.listViewAssemblies.Items.Clear();
-                this.listViewAssemblies.Items.AddRange( this.controller.GetAssemblies(selected.SubItems[0].Text));
+                this.listViewAssemblies.Items.AddRange(this.controller.GetAssemblies(selected.SubItems[0].Text));
                 this.listViewAssemblies.EndUpdate();
             }
         }
 
         private void tabControlMain_SelectedIndexChanged(object sender, EventArgs e)
         {
-            if(this.tabControlMain.SelectedTab == this.tabPageOutput)
+            if (this.tabControlMain.SelectedTab == this.tabPageOutput)
                 this.MoveOutputToEnd();
         }
 
         private void toolStripSplitButtonRefresh_ButtonClick(object sender, EventArgs e)
         {
-            if(this.tabControlMain.SelectedTab == this.tabPageProcesses)
+            if (this.tabControlMain.SelectedTab == this.tabPageProcesses)
                 this.RefreshProcesses();
             else if (this.tabControlMain.SelectedTab == this.tabPageAppDomain)
                 this.RefreshAppDomains();
             this.listViewHeap.Items.AddRange(this.controller.GetDumpHeapTypes());
             this.listViewHeap.EndUpdate();
 
-            if(!string.IsNullOrEmpty(this.textBoxTypeSearch.Text))
+            if (!string.IsNullOrEmpty(this.textBoxTypeSearch.Text))
             {
                 this.listViewHeap.BeginUpdate();
                 this.listViewHeap.Items.Clear();
         {
             Button button = (Button)sender;
 
-            OnInstanceSelected(button);           
+            OnInstanceSelected(button);
         }
 
         private void OnInstanceSelected(Button button)
                 Button otherButtons = item as Button;
                 if (otherButtons != null)
                 {
-                    otherButtons.Font = new Font(otherButtons.Font, FontStyle.Regular);                    
+                    otherButtons.Font = new Font(otherButtons.Font, FontStyle.Regular);
                 }
             }
 
             button.Font = new Font(button.Font, FontStyle.Bold);
             string address = ((InstanceInfoDetails)button.Tag).Address;
             string index = ((InstanceInfoDetails)button.Tag).Index;
-            string type = ((InstanceInfoDetails) button.Tag).Name;
+            string type = ((InstanceInfoDetails)button.Tag).Name;
 
             if (string.IsNullOrEmpty(index))
             {
             }
 
             var refs = this.controller.GetInstanceRef(address);
-            if(refs.Length > 0)
+            if (refs.Length > 0)
             {
                 this.splitContainerObjectRef.Panel1Collapsed = false;
                 this.listViewObjectRef.BeginUpdate();
             this.listViewHeap.BeginUpdate();
             this.listViewHeap.Items.Clear();
             this.listViewHeap.Items.AddRange(this.controller.FilterTypes(this.textBoxTypeSearch.Text));
-            this.listViewHeap.EndUpdate(); 
+            this.listViewHeap.EndUpdate();
         }
 
         private void textBoxTypeSearch_TextChanged(object sender, EventArgs e)
             {
                 var selected = this.listViewObjectDump.Items[this.listViewObjectDump.SelectedIndices[0]];
 
-                var selectedType = selected.SubItems[1].Text;
-
                 var selectedAddress = selected.SubItems[3].Text;
 
-                if (selectedType.EndsWith("[]") || selectedType.Equals("SZARRAY"))
-                {
-                    // the type is an array, display the collection
-                    this.splitContainerObjectDumpDetails.Panel2Collapsed = false;
-                    this.listViewFieldArray.BeginUpdate();
-                    this.listViewFieldArray.Items.Clear();
-                    this.listViewFieldArray.Items.AddRange(this.controller.GetArrayInstances(selectedAddress));
-                    this.listViewFieldArray.EndUpdate(); 
-                }
-                else
-                {
-                    Button newInstance = CreateInstanceButton(selectedAddress);
-                    DisplayInstanceDetails(newInstance);
-                }
+                Button newInstance = CreateInstanceButton(selectedAddress);
+                DisplayInstanceDetails(newInstance);
             }
         }
 
         private void DisplayInstanceDetails(Button newInstance)
-        {            
+        {
             if (!string.IsNullOrEmpty(newInstance.Text))
             {
                 // search the current object in breadcrumb
 
                             string addr = ((InstanceInfoDetails)button.Tag).Address;
                             string index = ((InstanceInfoDetails)button.Tag).Index;
-                            if (object.Equals(currentInstance.Address,addr) && object.Equals(currentInstance.Index, index))
+                            if (object.Equals(currentInstance.Address, addr) && object.Equals(currentInstance.Index, index))
                                 found = true;
                         }
                     }
 
         private void listViewProcesses_SelectedIndexChanged(object sender, EventArgs e)
         {
-            if(listViewProcesses.SelectedIndices.Count == 1)
+            if (listViewProcesses.SelectedIndices.Count == 1)
             {
                 this.toolStripButtonAttach.Enabled = true && !this.controller.Attached;
             }
                 {
                     var selectedField = this.listViewObjectDump.Items[this.listViewObjectDump.SelectedIndices[0]];
                     address = selectedField.SubItems[3].Text;
-                }                
+                }
 
                 this.splitContainerObjectDumpDetails.Panel2Collapsed = true;
                 Button newInstance = CreateInstanceButton(address, selected.SubItems[0].Text);
             var ascending = (bool)clickedCol.Tag;
 
             persistSort(listview, e.Column, ascending);
-            
+
             performSort(listview);
         }
 
 
-            Dictionary<ListView, KeyValuePair<int,bool>> columnSortByListViewMap = new Dictionary<ListView, KeyValuePair<int, bool>>();
+        Dictionary<ListView, KeyValuePair<int, bool>> columnSortByListViewMap = new Dictionary<ListView, KeyValuePair<int, bool>>();
 
         private void persistSort(ListView listViewToPersistSortOrder, int columnIndex, bool isAscending)
         {
-            var sortingDetails = new KeyValuePair<int,bool>(columnIndex, isAscending);
-                columnSortByListViewMap[listViewToPersistSortOrder] = sortingDetails;
+            var sortingDetails = new KeyValuePair<int, bool>(columnIndex, isAscending);
+            columnSortByListViewMap[listViewToPersistSortOrder] = sortingDetails;
         }
 
-            private void getSort(ListView listViewToRetriveSortInfoFor, out int columnIndex, out bool isAscending)
+        private void getSort(ListView listViewToRetriveSortInfoFor, out int columnIndex, out bool isAscending)
+        {
+            if (columnSortByListViewMap.ContainsKey(listViewToRetriveSortInfoFor))
             {
-                if(columnSortByListViewMap.ContainsKey(listViewToRetriveSortInfoFor))
-                {
-                    var sortingdetails = columnSortByListViewMap[listViewToRetriveSortInfoFor];
-                    columnIndex = sortingdetails.Key;
-                    isAscending = sortingdetails.Value;
-                }
-                else
-                {
-									
-                    columnIndex = 0;
-                    isAscending = true;
-                	var sortingdetails = new KeyValuePair<int, bool>(columnIndex, isAscending);
-									columnSortByListViewMap[listViewToRetriveSortInfoFor] = sortingdetails;
-                }
+                var sortingdetails = columnSortByListViewMap[listViewToRetriveSortInfoFor];
+                columnIndex = sortingdetails.Key;
+                isAscending = sortingdetails.Value;
             }
+            else
+            {
+
+                columnIndex = 0;
+                isAscending = true;
+                var sortingdetails = new KeyValuePair<int, bool>(columnIndex, isAscending);
+                columnSortByListViewMap[listViewToRetriveSortInfoFor] = sortingdetails;
+            }
+        }
 
         private void performSort(ListView listview/*, ColumnClickEventArgs e, bool ascending*/)
         {
-						// Get the number of items in the list.
+            // Get the number of items in the list.
             int columnIndexToSortOver;
             bool isAscending;
             getSort(listview, out columnIndexToSortOver, out isAscending);
             ArrayList SortArray = new ArrayList();
             for (int i = 0; i < numItems; i++)
             {
-                SortArray.Add(new SortWrapper(listview.Items[i],columnIndexToSortOver));
+                SortArray.Add(new SortWrapper(listview.Items[i], columnIndexToSortOver));
             }
 
             // Sort the elements in the ArrayList using a new instance of the SortComparer
             {
                 var selected = this.listViewObjectRef.Items[this.listViewObjectRef.SelectedIndices[0]];
 
-                var selectedType = selected.SubItems[1].Text;
-
                 var selectedAddress = selected.SubItems[0].Text;
 
-                if (selectedType.EndsWith("[]") || selectedType.Equals("SZARRAY"))
-                {
-                    // the type is an array, display the collection
-                    this.splitContainerObjectDumpDetails.Panel2Collapsed = false;
-                    this.listViewFieldArray.BeginUpdate();
-                    this.listViewFieldArray.Items.Clear();
-                    this.listViewFieldArray.Items.AddRange(this.controller.GetArrayInstances(selectedAddress));
-                    this.listViewFieldArray.EndUpdate();
-                }
-                else
-                {
-                    Button newInstance = CreateInstanceButton(selectedAddress);
-                    DisplayInstanceDetails(newInstance);
-                }
+                Button newInstance = CreateInstanceButton(selectedAddress);
+                DisplayInstanceDetails(newInstance);
             }
         }
 
         private void toolStripButtonDump_Click(object sender, EventArgs e)
         {
-            if(this.saveFileDialog.ShowDialog() == DialogResult.OK)
+            if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
             {
-                this.controller.SaveDump(this.saveFileDialog.FileName);                
+                this.controller.SaveDump(this.saveFileDialog.FileName);
             }
         }
 
         private void toolStripButtonOpenDump_Click(object sender, EventArgs e)
         {
-            if(this.openFileDialog.ShowDialog() == DialogResult.OK)
+            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
             {
-                this.AttachDump(this.openFileDialog.FileName);                
+                this.AttachDump(this.openFileDialog.FileName);
             }
         }
     }