private static Dictionary <int, WmiDataType> GetMofTypes(ManagementClass managementClass)
        {
            Dictionary <int, WmiDataType> dictionary = new Dictionary <int, WmiDataType>();

            PropertyDataCollection.PropertyDataEnumerator enumerator = managementClass.Properties.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    WmiDataType typeFromPropertyData = GetTypeFromPropertyData(enumerator.Current);
                    if (typeFromPropertyData != null)
                    {
                        dictionary.Add(typeFromPropertyData.Index, typeFromPropertyData);
                    }
                }
                return(dictionary);
            }
            finally
            {
                (enumerator as IDisposable)?.Dispose();
            }
        }
        private static void GetXmlFromWmiDataType(StringBuilder buffer, WmiDataType wmiDataType, IntPtr MofData, byte[] appData, ref int pos, ref string activityId, ref string relatedActivityId)
        {
            bool flag = false;

            buffer.Append("    ");
            if (pos >= appData.GetUpperBound(0))
            {
                buffer.Append(string.Format(CultureInfo.InvariantCulture, "<{0}/>", new object[1]
                {
                    wmiDataType.Name
                }));
            }
            else
            {
                if (!wmiDataType.IsXmlFragment)
                {
                    buffer.Append(string.Format(CultureInfo.InvariantCulture, "<{0}>", new object[1]
                    {
                        wmiDataType.Name
                    }));
                }
                if (typeof(Guid) == wmiDataType.Type)
                {
                    byte[] array = new byte[16];
                    Buffer.BlockCopy(appData, pos, array, 0, 16);
                    string text = new Guid(array).ToString("B", CultureInfo.InvariantCulture);
                    if (wmiDataType.IsActivityId)
                    {
                        activityId = text;
                    }
                    else if (wmiDataType.IsRelatedActivityId)
                    {
                        relatedActivityId = text;
                    }
                    else
                    {
                        buffer.Append(text);
                    }
                    pos += 16;
                    flag = true;
                }
                else if (typeof(string) == wmiDataType.Type)
                {
                    if (wmiDataType.StringTermination.Equals("NullTerminated", StringComparison.Ordinal))
                    {
                        if (wmiDataType.StringFormat.Equals("w", StringComparison.Ordinal))
                        {
                            StringBuilder stringBuilder = new StringBuilder();
                            bool          flag2         = false;
                            while (!flag2 && pos < appData.GetUpperBound(0))
                            {
                                char c = BitConverter.ToChar(appData, pos);
                                if (c == '\0')
                                {
                                    flag2 = true;
                                }
                                else
                                {
                                    stringBuilder.Append(c);
                                }
                                pos += 2;
                            }
                            buffer.Append(StringBuilderToXmlString(stringBuilder, !wmiDataType.IsXmlFragment));
                            flag = true;
                        }
                        else
                        {
                            ASCIIEncoding aSCIIEncoding  = new ASCIIEncoding();
                            StringBuilder stringBuilder2 = new StringBuilder();
                            bool          flag3          = false;
                            while (!flag3 && pos < appData.GetUpperBound(0))
                            {
                                char[] chars = aSCIIEncoding.GetChars(appData, pos, 1);
                                pos++;
                                if (chars[0] == '\0')
                                {
                                    flag3 = true;
                                }
                                else
                                {
                                    stringBuilder2.Append(chars[0]);
                                }
                            }
                            buffer.Append(StringBuilderToXmlString(stringBuilder2, !wmiDataType.IsXmlFragment));
                            flag = true;
                        }
                    }
                    else
                    {
                        buffer.Append("<NonNullTerminatedString>Not supported by ETW parser</NonNullTerminatedString>");
                    }
                }
                else if (typeof(ulong) == wmiDataType.Type)
                {
                    string value = BitConverter.ToUInt64(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value);
                    pos += 8;
                    flag = true;
                }
                else if (typeof(uint) == wmiDataType.Type)
                {
                    string value2 = BitConverter.ToUInt32(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value2);
                    pos += 4;
                    flag = true;
                }
                else if (typeof(ushort) == wmiDataType.Type)
                {
                    string value3 = BitConverter.ToUInt16(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value3);
                    pos += 2;
                    flag = true;
                }
                else if (typeof(long) == wmiDataType.Type)
                {
                    string value4 = BitConverter.ToInt64(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value4);
                    pos += 8;
                    flag = true;
                }
                else if (typeof(int) == wmiDataType.Type)
                {
                    string value5 = BitConverter.ToInt32(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value5);
                    pos += 4;
                    flag = true;
                }
                else if (typeof(short) == wmiDataType.Type)
                {
                    string value6 = BitConverter.ToInt16(appData, pos).ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value6);
                    pos += 2;
                    flag = true;
                }
                else if (typeof(byte) == wmiDataType.Type)
                {
                    string value7 = appData[pos].ToString(CultureInfo.InvariantCulture);
                    buffer.Append(value7);
                    pos++;
                    flag = true;
                }
                if (!flag)
                {
                    buffer.Append(wmiDataType.Type.ToString());
                }
                if (!wmiDataType.IsXmlFragment)
                {
                    buffer.Append(string.Format(CultureInfo.InvariantCulture, "</{0}>", new object[1]
                    {
                        wmiDataType.Name
                    }));
                }
            }
        }