// Token: 0x0600345E RID: 13406 RVA: 0x000CB178 File Offset: 0x000C9378
        private string CreateManifestString()
        {
            if (this.channelTab != null)
            {
                this.sb.Append(" <channels>").AppendLine();
                List <KeyValuePair <int, ManifestBuilder.ChannelInfo> > list = new List <KeyValuePair <int, ManifestBuilder.ChannelInfo> >();
                foreach (KeyValuePair <int, ManifestBuilder.ChannelInfo> item in this.channelTab)
                {
                    list.Add(item);
                }
                list.Sort((KeyValuePair <int, ManifestBuilder.ChannelInfo> p1, KeyValuePair <int, ManifestBuilder.ChannelInfo> p2) => - Comparer <ulong> .Default.Compare(p1.Value.Keywords, p2.Value.Keywords));
                foreach (KeyValuePair <int, ManifestBuilder.ChannelInfo> keyValuePair in list)
                {
                    int key = keyValuePair.Key;
                    ManifestBuilder.ChannelInfo value = keyValuePair.Value;
                    string text  = null;
                    string text2 = "channel";
                    bool   flag  = false;
                    string text3 = null;
                    if (value.Attribs != null)
                    {
                        EventChannelAttribute attribs = value.Attribs;
                        if (Enum.IsDefined(typeof(EventChannelType), attribs.EventChannelType))
                        {
                            text = attribs.EventChannelType.ToString();
                        }
                        flag = attribs.Enabled;
                    }
                    if (text3 == null)
                    {
                        text3 = this.providerName + "/" + value.Name;
                    }
                    this.sb.Append("  <").Append(text2);
                    this.sb.Append(" chid=\"").Append(value.Name).Append("\"");
                    this.sb.Append(" name=\"").Append(text3).Append("\"");
                    if (text2 == "channel")
                    {
                        this.WriteMessageAttrib(this.sb, "channel", value.Name, null);
                        this.sb.Append(" value=\"").Append(key).Append("\"");
                        if (text != null)
                        {
                            this.sb.Append(" type=\"").Append(text).Append("\"");
                        }
                        this.sb.Append(" enabled=\"").Append(flag.ToString().ToLower()).Append("\"");
                    }
                    this.sb.Append("/>").AppendLine();
                }
                this.sb.Append(" </channels>").AppendLine();
            }
            if (this.taskTab != null)
            {
                this.sb.Append(" <tasks>").AppendLine();
                List <int> list2 = new List <int>(this.taskTab.Keys);
                list2.Sort();
                foreach (int num in list2)
                {
                    this.sb.Append("  <task");
                    this.WriteNameAndMessageAttribs(this.sb, "task", this.taskTab[num]);
                    this.sb.Append(" value=\"").Append(num).Append("\"/>").AppendLine();
                }
                this.sb.Append(" </tasks>").AppendLine();
            }
            if (this.mapsTab != null)
            {
                this.sb.Append(" <maps>").AppendLine();
                foreach (Type type in this.mapsTab.Values)
                {
                    bool   flag2  = EventSource.GetCustomAttributeHelper(type, typeof(FlagsAttribute), this.flags) != null;
                    string value2 = flag2 ? "bitMap" : "valueMap";
                    this.sb.Append("  <").Append(value2).Append(" name=\"").Append(type.Name).Append("\">").AppendLine();
                    FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
                    foreach (FieldInfo fieldInfo in fields)
                    {
                        object rawConstantValue = fieldInfo.GetRawConstantValue();
                        if (rawConstantValue != null)
                        {
                            long num2;
                            if (rawConstantValue is int)
                            {
                                num2 = (long)((int)rawConstantValue);
                            }
                            else
                            {
                                if (!(rawConstantValue is long))
                                {
                                    goto IL_4D1;
                                }
                                num2 = (long)rawConstantValue;
                            }
                            if (!flag2 || ((num2 & num2 - 1L) == 0L && num2 != 0L))
                            {
                                this.sb.Append("   <map value=\"0x").Append(num2.ToString("x", CultureInfo.InvariantCulture)).Append("\"");
                                this.WriteMessageAttrib(this.sb, "map", type.Name + "." + fieldInfo.Name, fieldInfo.Name);
                                this.sb.Append("/>").AppendLine();
                            }
                        }
                        IL_4D1 :;
                    }
                    this.sb.Append("  </").Append(value2).Append(">").AppendLine();
                }
                this.sb.Append(" </maps>").AppendLine();
            }
            this.sb.Append(" <opcodes>").AppendLine();
            List <int> list3 = new List <int>(this.opcodeTab.Keys);

            list3.Sort();
            foreach (int num3 in list3)
            {
                this.sb.Append("  <opcode");
                this.WriteNameAndMessageAttribs(this.sb, "opcode", this.opcodeTab[num3]);
                this.sb.Append(" value=\"").Append(num3).Append("\"/>").AppendLine();
            }
            this.sb.Append(" </opcodes>").AppendLine();
            if (this.keywordTab != null)
            {
                this.sb.Append(" <keywords>").AppendLine();
                List <ulong> list4 = new List <ulong>(this.keywordTab.Keys);
                list4.Sort();
                foreach (ulong key2 in list4)
                {
                    this.sb.Append("  <keyword");
                    this.WriteNameAndMessageAttribs(this.sb, "keyword", this.keywordTab[key2]);
                    this.sb.Append(" mask=\"0x").Append(key2.ToString("x", CultureInfo.InvariantCulture)).Append("\"/>").AppendLine();
                }
                this.sb.Append(" </keywords>").AppendLine();
            }
            this.sb.Append(" <events>").AppendLine();
            this.sb.Append(this.events);
            this.sb.Append(" </events>").AppendLine();
            this.sb.Append(" <templates>").AppendLine();
            if (this.templates.Length > 0)
            {
                this.sb.Append(this.templates);
            }
            else
            {
                this.sb.Append("    <template tid=\"_empty\"></template>").AppendLine();
            }
            this.sb.Append(" </templates>").AppendLine();
            this.sb.Append("</provider>").AppendLine();
            this.sb.Append("</events>").AppendLine();
            this.sb.Append("</instrumentation>").AppendLine();
            this.sb.Append("<localization>").AppendLine();
            List <CultureInfo> list5;

            if (this.resources != null && (this.flags & EventManifestOptions.AllCultures) != EventManifestOptions.None)
            {
                list5 = ManifestBuilder.GetSupportedCultures(this.resources);
            }
            else
            {
                list5 = new List <CultureInfo>();
                list5.Add(CultureInfo.CurrentUICulture);
            }
            string[] array2 = new string[this.stringTab.Keys.Count];
            this.stringTab.Keys.CopyTo(array2, 0);
            ArraySortHelper <string> .IntrospectiveSort(array2, 0, array2.Length, Comparer <string> .Default);

            foreach (CultureInfo cultureInfo in list5)
            {
                this.sb.Append(" <resources culture=\"").Append(cultureInfo.Name).Append("\">").AppendLine();
                this.sb.Append("  <stringTable>").AppendLine();
                foreach (string text4 in array2)
                {
                    string localizedMessage = this.GetLocalizedMessage(text4, cultureInfo, true);
                    this.sb.Append("   <string id=\"").Append(text4).Append("\" value=\"").Append(localizedMessage).Append("\"/>").AppendLine();
                }
                this.sb.Append("  </stringTable>").AppendLine();
                this.sb.Append(" </resources>").AppendLine();
            }
            this.sb.Append("</localization>").AppendLine();
            this.sb.AppendLine("</instrumentationManifest>");
            return(this.sb.ToString());
        }
示例#2
0
        private string CreateManifestString()
        {
            if (this.channelTab != null)
            {
                this.sb.Append(" <channels>").AppendLine();
                List <KeyValuePair <int, ManifestBuilder.ChannelInfo> > keyValuePairList = new List <KeyValuePair <int, ManifestBuilder.ChannelInfo> >();
                foreach (KeyValuePair <int, ManifestBuilder.ChannelInfo> keyValuePair in this.channelTab)
                {
                    keyValuePairList.Add(keyValuePair);
                }
                keyValuePairList.Sort((Comparison <KeyValuePair <int, ManifestBuilder.ChannelInfo> >)((p1, p2) => - Comparer <ulong> .Default.Compare(p1.Value.Keywords, p2.Value.Keywords)));
                foreach (KeyValuePair <int, ManifestBuilder.ChannelInfo> keyValuePair in keyValuePairList)
                {
                    int key = keyValuePair.Key;
                    ManifestBuilder.ChannelInfo channelInfo = keyValuePair.Value;
                    string str1 = (string)null;
                    string str2 = "channel";
                    bool   flag = false;
                    string str3 = (string)null;
                    if (channelInfo.Attribs != null)
                    {
                        EventChannelAttribute channelAttribute = channelInfo.Attribs;
                        if (Enum.IsDefined(typeof(EventChannelType), (object)channelAttribute.EventChannelType))
                        {
                            str1 = channelAttribute.EventChannelType.ToString();
                        }
                        flag = channelAttribute.Enabled;
                    }
                    if (str3 == null)
                    {
                        str3 = this.providerName + "/" + channelInfo.Name;
                    }
                    this.sb.Append("  <").Append(str2);
                    this.sb.Append(" chid=\"").Append(channelInfo.Name).Append("\"");
                    this.sb.Append(" name=\"").Append(str3).Append("\"");
                    if (str2 == "channel")
                    {
                        this.WriteMessageAttrib(this.sb, "channel", channelInfo.Name, (string)null);
                        this.sb.Append(" value=\"").Append(key).Append("\"");
                        if (str1 != null)
                        {
                            this.sb.Append(" type=\"").Append(str1).Append("\"");
                        }
                        this.sb.Append(" enabled=\"").Append(flag.ToString().ToLower()).Append("\"");
                    }
                    this.sb.Append("/>").AppendLine();
                }
                this.sb.Append(" </channels>").AppendLine();
            }
            if (this.taskTab != null)
            {
                this.sb.Append(" <tasks>").AppendLine();
                List <int> intList = new List <int>((IEnumerable <int>) this.taskTab.Keys);
                intList.Sort();
                foreach (int index in intList)
                {
                    this.sb.Append("  <task");
                    this.WriteNameAndMessageAttribs(this.sb, "task", this.taskTab[index]);
                    this.sb.Append(" value=\"").Append(index).Append("\"/>").AppendLine();
                }
                this.sb.Append(" </tasks>").AppendLine();
            }
            if (this.mapsTab != null)
            {
                this.sb.Append(" <maps>").AppendLine();
                foreach (Type type in this.mapsTab.Values)
                {
                    bool   flag = EventSource.GetCustomAttributeHelper((MemberInfo)type, typeof(FlagsAttribute), this.flags) != null;
                    string str  = flag ? "bitMap" : "valueMap";
                    this.sb.Append("  <").Append(str).Append(" name=\"").Append(type.Name).Append("\">").AppendLine();
                    foreach (FieldInfo field in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public))
                    {
                        object rawConstantValue = field.GetRawConstantValue();
                        if (rawConstantValue != null)
                        {
                            long num1;
                            if (rawConstantValue is int)
                            {
                                num1 = (long)(int)rawConstantValue;
                            }
                            else if (rawConstantValue is long)
                            {
                                num1 = (long)rawConstantValue;
                            }
                            else
                            {
                                continue;
                            }
                            if (flag)
                            {
                                long num2 = num1;
                                long num3 = 1;
                                long num4 = num2 - num3;
                                if ((num2 & num4) != 0L || num1 == 0L)
                                {
                                    continue;
                                }
                            }
                            this.sb.Append("   <map value=\"0x").Append(num1.ToString("x", (IFormatProvider)CultureInfo.InvariantCulture)).Append("\"");
                            this.WriteMessageAttrib(this.sb, "map", type.Name + "." + field.Name, field.Name);
                            this.sb.Append("/>").AppendLine();
                        }
                    }
                    this.sb.Append("  </").Append(str).Append(">").AppendLine();
                }
                this.sb.Append(" </maps>").AppendLine();
            }
            this.sb.Append(" <opcodes>").AppendLine();
            List <int> intList1 = new List <int>((IEnumerable <int>) this.opcodeTab.Keys);

            intList1.Sort();
            foreach (int index in intList1)
            {
                this.sb.Append("  <opcode");
                this.WriteNameAndMessageAttribs(this.sb, "opcode", this.opcodeTab[index]);
                this.sb.Append(" value=\"").Append(index).Append("\"/>").AppendLine();
            }
            this.sb.Append(" </opcodes>").AppendLine();
            if (this.keywordTab != null)
            {
                this.sb.Append(" <keywords>").AppendLine();
                List <ulong> ulongList = new List <ulong>((IEnumerable <ulong>) this.keywordTab.Keys);
                ulongList.Sort();
                foreach (ulong index in ulongList)
                {
                    this.sb.Append("  <keyword");
                    this.WriteNameAndMessageAttribs(this.sb, "keyword", this.keywordTab[index]);
                    this.sb.Append(" mask=\"0x").Append(index.ToString("x", (IFormatProvider)CultureInfo.InvariantCulture)).Append("\"/>").AppendLine();
                }
                this.sb.Append(" </keywords>").AppendLine();
            }
            this.sb.Append(" <events>").AppendLine();
            this.sb.Append((object)this.events);
            this.sb.Append(" </events>").AppendLine();
            this.sb.Append(" <templates>").AppendLine();
            if (this.templates.Length > 0)
            {
                this.sb.Append((object)this.templates);
            }
            else
            {
                this.sb.Append("    <template tid=\"_empty\"></template>").AppendLine();
            }
            this.sb.Append(" </templates>").AppendLine();
            this.sb.Append("</provider>").AppendLine();
            this.sb.Append("</events>").AppendLine();
            this.sb.Append("</instrumentation>").AppendLine();
            this.sb.Append("<localization>").AppendLine();
            List <CultureInfo> cultureInfoList;

            if (this.resources != null && (this.flags & EventManifestOptions.AllCultures) != EventManifestOptions.None)
            {
                cultureInfoList = ManifestBuilder.GetSupportedCultures(this.resources);
            }
            else
            {
                cultureInfoList = new List <CultureInfo>();
                cultureInfoList.Add(CultureInfo.CurrentUICulture);
            }
            string[] strArray = new string[this.stringTab.Keys.Count];
            this.stringTab.Keys.CopyTo(strArray, 0);
            ArraySortHelper <string> .IntrospectiveSort(strArray, 0, strArray.Length, (IComparer <string>) Comparer <string> .Default);

            foreach (CultureInfo ci in cultureInfoList)
            {
                this.sb.Append(" <resources culture=\"").Append(ci.Name).Append("\">").AppendLine();
                this.sb.Append("  <stringTable>").AppendLine();
                foreach (string key in strArray)
                {
                    string localizedMessage = this.GetLocalizedMessage(key, ci, true);
                    this.sb.Append("   <string id=\"").Append(key).Append("\" value=\"").Append(localizedMessage).Append("\"/>").AppendLine();
                }
                this.sb.Append("  </stringTable>").AppendLine();
                this.sb.Append(" </resources>").AppendLine();
            }
            this.sb.Append("</localization>").AppendLine();
            this.sb.AppendLine("</instrumentationManifest>");
            return(this.sb.ToString());
        }