// 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());
        }
 // Token: 0x06003457 RID: 13399 RVA: 0x000CAC48 File Offset: 0x000C8E48
 public void StartEvent(string eventName, EventAttribute eventAttribute)
 {
     this.eventName         = eventName;
     this.numParams         = 0;
     this.byteArrArgIndices = null;
     this.events.Append("  <event").Append(" value=\"").Append(eventAttribute.EventId).Append("\"").Append(" version=\"").Append(eventAttribute.Version).Append("\"").Append(" level=\"").Append(ManifestBuilder.GetLevelName(eventAttribute.Level)).Append("\"").Append(" symbol=\"").Append(eventName).Append("\"");
     this.WriteMessageAttrib(this.events, "event", eventName, eventAttribute.Message);
     if (eventAttribute.Keywords != EventKeywords.None)
     {
         this.events.Append(" keywords=\"").Append(this.GetKeywords((ulong)eventAttribute.Keywords, eventName)).Append("\"");
     }
     if (eventAttribute.Opcode != EventOpcode.Info)
     {
         this.events.Append(" opcode=\"").Append(this.GetOpcodeName(eventAttribute.Opcode, eventName)).Append("\"");
     }
     if (eventAttribute.Task != EventTask.None)
     {
         this.events.Append(" task=\"").Append(this.GetTaskName(eventAttribute.Task, eventName)).Append("\"");
     }
     if (eventAttribute.Channel != EventChannel.None)
     {
         this.events.Append(" channel=\"").Append(this.GetChannelName(eventAttribute.Channel, eventName, eventAttribute.Message)).Append("\"");
     }
 }
Example #3
0
        // adds a enumeration (keyword, opcode, task or channel) represented by 'staticField'
        // to the manifest.  
        private static void AddProviderEnumKind(ManifestBuilder manifest, FieldInfo staticField, string providerEnumKind)
        {
            Type staticFieldType = staticField.FieldType;
            if (staticFieldType == typeof(EventOpcode))
            {
                if (providerEnumKind != "Opcodes") goto Error;
                int value = (int)staticField.GetRawConstantValue();
                if (value <= 10)
                    throw new ArgumentException(Environment.GetResourceString("EventSource_ReservedOpcode"));
                manifest.AddOpcode(staticField.Name, value);
            }
            else if (staticFieldType == typeof(EventTask))
            {
                if (providerEnumKind != "Tasks") goto Error;
                manifest.AddTask(staticField.Name, (int)staticField.GetRawConstantValue());
            }
            else if (staticFieldType == typeof(EventKeywords))
            {
                if (providerEnumKind != "Keywords") goto Error;
                manifest.AddKeyword(staticField.Name, (ulong)(long)staticField.GetRawConstantValue());
            }
#if FEATURE_MANAGED_ETW_CHANNELS
            else if (staticFieldType == typeof(EventChannel))
            {
                if (providerEnumKind != "Channels") goto Error;
                var channelAttribute = (ChannelAttribute)GetCustomAttributeHelper(staticField, typeof(ChannelAttribute));
                manifest.AddChannel(staticField.Name, (byte)staticField.GetRawConstantValue(), channelAttribute);
            }
#endif
            return;
        Error:
            throw new ArgumentException(Environment.GetResourceString("EventSource_EnumKindMismatch",  staticField.FieldType.Name, providerEnumKind));
        }
Example #4
0
        // Use reflection to look at the attributes of a class, and generate a manifest for it (as UTF8) and
        // return the UTF8 bytes.  It also sets up the code:EventData structures needed to dispatch events
        // at run time.  'source' is the event source to place the descriptors.  If it is null,
        // then the descriptors are not creaed, and just the manifest is generated.  
        private static byte[] CreateManifestAndDescriptors(Type eventSourceType, string eventSourceDllName, EventSource source)
        {
            MethodInfo[] methods = eventSourceType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            EventAttribute defaultEventAttribute;
            int eventId = 1;        // The number given to an event that does not have a explicitly given ID. 
            EventMetadata[] eventData = null;
            Dictionary<string, string> eventsByName = null;
            if (source != null)
                eventData = new EventMetadata[methods.Length];

            // See if we have localization information.  
            ResourceManager resources = null;
            EventSourceAttribute eventSourceAttrib = (EventSourceAttribute)GetCustomAttributeHelper(eventSourceType, typeof(EventSourceAttribute));
            if (eventSourceAttrib != null && eventSourceAttrib.LocalizationResources != null)
                resources = new ResourceManager(eventSourceAttrib.LocalizationResources, eventSourceType.Assembly);

            ManifestBuilder manifest = new ManifestBuilder(GetName(eventSourceType), GetGuid(eventSourceType), eventSourceDllName, resources);

            // Collect task, opcode, keyword and channel information
#if FEATURE_MANAGED_ETW_CHANNELS
            foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes", "Channels" })
#else
            foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes" })
#endif
            {
                Type nestedType = eventSourceType.GetNestedType(providerEnumKind);
                if (nestedType != null)
                {
                    foreach (FieldInfo staticField in nestedType.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
                    {
                        AddProviderEnumKind(manifest, staticField, providerEnumKind);
                    }
                }
            }

            for (int i = 0; i < methods.Length; i++)
            {
                MethodInfo method = methods[i];
                ParameterInfo[] args = method.GetParameters();

                // Get the EventDescriptor (from the Custom attributes)
                EventAttribute eventAttribute = (EventAttribute)GetCustomAttributeHelper(method, typeof(EventAttribute));

                // Methods that don't return void can't be events.  
                if (method.ReturnType != typeof(void))
                {
                    if (eventAttribute != null)
                        throw new ArgumentException(Environment.GetResourceString("EventSource_AttributeOnNonVoid", method.Name));
                    continue;
                }
                if (method.IsVirtual || method.IsStatic)
                {
                    continue;
                }

                if (eventAttribute == null)
                {
                    // If we explictly mark the method as not being an event, then honor that.  
                    if (GetCustomAttributeHelper(method, typeof(NonEventAttribute)) != null)
                        continue;

                    defaultEventAttribute = new EventAttribute(eventId);
                    eventAttribute = defaultEventAttribute;
                }
                else if (eventAttribute.EventId <= 0)
                    throw new ArgumentException(Environment.GetResourceString("EventSource_NeedPositiveId"));
                else if ((ulong)eventAttribute.Keywords >= 0x0000100000000000UL)
                    throw new ArgumentException(Environment.GetResourceString("EventSource_ReservedKeywords"));
                eventId++;

                // Auto-assign tasks, starting with the highest task number and working back 
                if (eventAttribute.Opcode == EventOpcode.Info && eventAttribute.Task == EventTask.None)
                    eventAttribute.Task = (EventTask)(0xFFFE - eventAttribute.EventId);

                manifest.StartEvent(method.Name, eventAttribute);
                for (int fieldIdx = 0; fieldIdx < args.Length; fieldIdx++)
                {
                    // If the first parameter is 'RelatedActivityId' then skip it.  
                    if (fieldIdx == 0 && args[fieldIdx].ParameterType == typeof(Guid) && 
                        string.Compare(args[fieldIdx].Name, "RelatedActivityId", StringComparison.OrdinalIgnoreCase) == 0)
                        continue;
                    manifest.AddEventParameter(args[fieldIdx].ParameterType, args[fieldIdx].Name);
                }
                manifest.EndEvent();

                if (source != null)
                {
                    // Do checking for user errors (optional, but nto a big deal so we do it).  
                    DebugCheckEvent(ref eventsByName, eventData, method, eventAttribute);
                    AddEventDescriptor(ref eventData, method.Name, eventAttribute, args);
                }
            }

            if (source != null)
            {
                TrimEventDescriptors(ref eventData);
                source.m_eventData = eventData;     // officaly initialize it. We do this at most once (it is racy otherwise). 
            }

            return manifest.CreateManifest();
        }
Example #5
0
        private string TranslateToManifestConvention(string eventMessage, string evtName)
        {
            StringBuilder stringBuilder = (StringBuilder)null;
            int           writtenSoFar  = 0;
            int           i             = 0;

            while (i < eventMessage.Length)
            {
                if ((int)eventMessage[i] == 37)
                {
                    ManifestBuilder.UpdateStringBuilder(ref stringBuilder, eventMessage, writtenSoFar, i - writtenSoFar);
                    stringBuilder.Append("%%");
                    ++i;
                    writtenSoFar = i;
                }
                else if (i < eventMessage.Length - 1 && ((int)eventMessage[i] == 123 && (int)eventMessage[i + 1] == 123 || (int)eventMessage[i] == 125 && (int)eventMessage[i + 1] == 125))
                {
                    ManifestBuilder.UpdateStringBuilder(ref stringBuilder, eventMessage, writtenSoFar, i - writtenSoFar);
                    stringBuilder.Append(eventMessage[i]);
                    ++i;
                    ++i;
                    writtenSoFar = i;
                }
                else if ((int)eventMessage[i] == 123)
                {
                    int num1 = i;
                    ++i;
                    int idx = 0;
                    int num2;
                    for (; i < eventMessage.Length && char.IsDigit(eventMessage[i]); i = num2 + 1)
                    {
                        idx  = idx * 10 + (int)eventMessage[i] - 48;
                        num2 = i;
                    }
                    if (i < eventMessage.Length && (int)eventMessage[i] == 125)
                    {
                        ++i;
                        ManifestBuilder.UpdateStringBuilder(ref stringBuilder, eventMessage, writtenSoFar, num1 - writtenSoFar);
                        int manifestConvention = this.TranslateIndexToManifestConvention(idx, evtName);
                        stringBuilder.Append('%').Append(manifestConvention);
                        if (i < eventMessage.Length && (int)eventMessage[i] == 33)
                        {
                            ++i;
                            stringBuilder.Append("%!");
                        }
                        writtenSoFar = i;
                    }
                    else
                    {
                        this.ManifestError(Environment.GetResourceString("EventSource_UnsupportedMessageProperty", (object)evtName, (object)eventMessage), false);
                    }
                }
                else
                {
                    int index;
                    if ((index = "&<>'\"\r\n\t".IndexOf(eventMessage[i])) >= 0)
                    {
                        string[] strArray = new string[8] {
                            "&amp;", "&lt;", "&gt;", "&apos;", "&quot;", "%r", "%n", "%t"
                        };
                        ((Action <char, string>)((ch, escape) =>
                        {
                            ManifestBuilder.UpdateStringBuilder(ref stringBuilder, eventMessage, writtenSoFar, i - writtenSoFar);
                            ++i;
                            stringBuilder.Append(escape);
                            writtenSoFar = i;
                        }))(eventMessage[i], strArray[index]);
                    }
                    else
                    {
                        ++i;
                    }
                }
            }
            if (stringBuilder == null)
            {
                return(eventMessage);
            }
            ManifestBuilder.UpdateStringBuilder(ref stringBuilder, eventMessage, writtenSoFar, i - writtenSoFar);
            return(stringBuilder.ToString());
        }
Example #6
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());
        }