Exemple #1
0
        static public RICustomData GetCollection(IEnumerable enumerator, ObjectScope scope)
        {
            RICustomDataFieldIdType             fType = RICustomDataFieldIdType.Integer;
            RICustomDataColumnJustificationType sIndexJustification = RICustomDataColumnJustificationType.Right;
            string sIndex = "Index";

            if (enumerator is IDictionary)
            {
                sIndex = "Key";
                fType  = RICustomDataFieldIdType.String;
                sIndexJustification = RICustomDataColumnJustificationType.Left;
            }

            List <RICustomDataColumn> columns = new List <RICustomDataColumn>();

            columns.Add(new RICustomDataColumn(sIndex, fType, null, null, sIndexJustification));
            columns.Add(new RICustomDataColumn("Value"));
            columns.Add(new RICustomDataColumn("Type"));

            RICustomData cData = new RICustomData(enumerator.GetType().FullName, columns, true, false);

            cData.AllowSort  = true;
            cData.HasDetails = scope != ObjectScope.None;

            using (var pool = FastFormatterPool.Pool.Container())
            {
                if (enumerator is IDictionary)
                {
                    IDictionary collection = (IDictionary)enumerator;
                    foreach (Object key in collection.Keys)
                    {
                        Object          value = collection[key];
                        RICustomDataRow row   = cData.AddRow(key != null ? key.ToString() : null, value != null ? value.ToString() : null, value != null ? value.GetType().FullName : null);
                        if (!cData.HasDetails || value == null)
                        {
                            continue;
                        }

                        row.SetExtraData(pool.Instance, ObjectBuilder.BuildObjectPropertyMap(value, scope));
                    }
                }
                else
                {
                    Int32 index = 0;
                    foreach (Object value in enumerator)
                    {
                        RICustomDataRow row = cData.AddRow(index++, value != null ? value.ToString() : null, value != null ? value.GetType().FullName : null);
                        if (!cData.HasDetails || value == null)
                        {
                            continue;
                        }

                        row.SetExtraData(pool.Instance, ObjectBuilder.BuildObjectPropertyMap(value, scope));
                    }
                }
            }

            return(cData);
        }
Exemple #2
0
        static public RICustomData GetLoadedAssemblies()
        {
            List <RICustomDataColumn> columns = new List <RICustomDataColumn>();

            columns.Add(new RICustomDataColumn("Assembly"));
            columns.Add(new RICustomDataColumn("Version"));
            columns.Add(new RICustomDataColumn("Culture"));
            columns.Add(new RICustomDataColumn("Strong Named"));
            columns.Add(new RICustomDataColumn("GAC"));

            RICustomData cData = new RICustomData(string.Format("{0}: Loaded Assemblies", AppDomain.CurrentDomain.FriendlyName), columns, true, false)
            {
                AllowSort = true
            };

            string tmpStr = string.Empty;

            foreach (Assembly assem in AppDomain.CurrentDomain.GetAssemblies())
            {
                RICustomDataRow row = cData.AddRow();

                Int32    j    = 0;
                string[] fns1 = assem.FullName.Split(',');
                foreach (string s1 in fns1)
                {
                    if (j != 0)
                    {
                        string[] fns2 = s1.Split('=');
                        tmpStr = fns2[1].Trim();

                        switch (j)
                        {
                        case 1: row.AddField(tmpStr); break;

                        case 2: row.AddField(tmpStr); break;

                        case 3: row.AddField((tmpStr != "null").ToString()); break;
                        }
                    }
                    else
                    {
                        row.AddField(s1.Trim());
                    }

                    j++;
                }

                row.AddField(assem.GlobalAssemblyCache.ToString());
            }

            return(cData);
        }
Exemple #3
0
        static public RICustomData GetThreadInformation(Thread aThread)
        {
            List <RICustomDataColumn> columns = new List <RICustomDataColumn>
            {
                new RICustomDataColumn("Property"),
                new RICustomDataColumn("Value")
            };

            RICustomData cData = new RICustomData("Thread Information", columns, false, true);

            cData.AddRow("Name", aThread.Name);
            cData.AddRow("HashCode", aThread.GetHashCode().ToString());
            cData.AddRow("IsAlive", aThread.IsAlive.ToString());
            cData.AddRow("IsBackground", aThread.IsBackground.ToString());
            cData.AddRow("IsThreadPoolThread", aThread.IsThreadPoolThread.ToString());
            cData.AddRow("Priority", aThread.Priority.ToString());
            cData.AddRow("ThreadState", aThread.ThreadState.ToString());
            cData.AddRow("ApartmentState", aThread.GetApartmentState().ToString());
            cData.AddRow("CurrentCulture", aThread.CurrentCulture.ToString());
            cData.AddRow("CurrentUICulture", aThread.CurrentUICulture.ToString());

            return(cData);
        }
Exemple #4
0
        static public RICustomData GetLoadedProcesses()
        {
            List <RICustomDataColumn> columns = new List <RICustomDataColumn>();

            columns.Add(new RICustomDataColumn("Image Name"));
            columns.Add(new RICustomDataColumn("Mem Usage", RICustomDataFieldIdType.Integer, "{0:N0} KB", null, RICustomDataColumnJustificationType.Right));
            columns.Add(new RICustomDataColumn("Virtual Mem Usage", RICustomDataFieldIdType.Integer, "{0:N0} KB", null, RICustomDataColumnJustificationType.Right));
            columns.Add(new RICustomDataColumn("Peak Mem Usage", RICustomDataFieldIdType.Integer, "{0:N0} KB", null, RICustomDataColumnJustificationType.Right));
            columns.Add(new RICustomDataColumn("Thread Count", RICustomDataFieldIdType.Integer, "{0:N0}", null, RICustomDataColumnJustificationType.Right));

            RICustomData cData = new RICustomData("Loaded Processes", columns, true, false)
            {
                AllowSort = true
            };
            List <Process> processes = new List <Process>(Process.GetProcesses());

            processes.Sort(CompareProcess);

            foreach (Process p in processes)
            {
                using (p)
                {
                    if (p.ProcessName.Trim().ToLower() == "idle")
                    {
                        continue;
                    }

                    RICustomDataRow row = cData.AddRow();

                    row.AddField(p.ProcessName);
                    row.AddField((Int32)(p.WorkingSet64 / 1024));
                    row.AddField((Int32)(p.PrivateMemorySize64 / 1024));
                    row.AddField((Int32)(p.PeakWorkingSet64 / 1024));
                    row.AddField((Int32)p.Threads.Count);
                }
            }

            processes.Clear();
            processes.Capacity = 0;

            return(cData);
        }
Exemple #5
0
        //---------------------------------------------------------------------
        static RICustomData GetCustomData1()
        {
            Random rnd = new Random((Int32)DateTime.Now.Ticks);

            List <RICustomDataColumn> columns = new List <RICustomDataColumn>();

            columns.Add(new RICustomDataColumn("Column1"));
            columns.Add(new RICustomDataColumn("Column2"));
            columns.Add(new RICustomDataColumn("Column3"));
            columns.Add(new RICustomDataColumn("Column4"));

            RICustomData cData = new RICustomData("My Custom Data", columns, true, false);

            cData.AddRow("Ross", "Test");

            RICustomDataCategory cat = cData.AddCategory("Category1");

            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "a";
                cat.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}{1}", i, crap), String.Format("field3{0}", i));
            }

            cat = cat.AddCategory("Category2");
            RICustomDataCategory cat2 = cat;

            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "b";
                cat.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}", i), String.Format("field3{0}", i), String.Format("field4{0}", i));
            }

            cat = cat.AddCategory("Category3");
            RICustomDataCategory cat3 = cat.AddCategory("Category3b");

            cat3.AddRow("Ross", "Test");

            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "c";
                cat.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}", i), String.Format("field3{0}", i), String.Format("field4{0}", i));
            }

            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "bx";
                cat2.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}", i), String.Format("field3{0}{1}", i, crap));
            }

            cat = cData.AddCategory("Category1a");
            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "a1";
                cat.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}{1}", i, crap), String.Format("field3{0}", i));
            }

            for (Int32 i = 0; i < 3; i++)
            {
                const String crap = "d";
                cData.AddRow(String.Format("field1{0}{1}", i, crap), String.Format("field2{0}", i), String.Format("field3{0}{1}", i, crap));
            }

            return(cData);
        }