예제 #1
0
        private ulong AddChannelKeyword(EventChannel channel)
        {
            ulong num;

            if (this.channelKeywords == null)
            {
                this.channelKeywords = new Dictionary <int, ulong>();
            }
            if (!this.channelKeywords.TryGetValue(channel, out num))
            {
                num = this.channelReservedKeywordMask;
                ManifestBuilder manifestBuilder = this;
                manifestBuilder.channelReservedKeywordMask = manifestBuilder.channelReservedKeywordMask >> 1;
                this.channelKeywords[channel] = num;
            }
            return(num);
        }
예제 #2
0
        private void WriteMessageAttrib(StringBuilder stringBuilder, string elementName, string name, string value)
        {
            string str = string.Concat(elementName, "_", name);

            if (this.resources != null)
            {
                string str1 = this.resources.GetString(str);
                if (str1 != null)
                {
                    value = str1;
                }
            }
            if (value == null)
            {
                return;
            }
            if (elementName == "event")
            {
                value = ManifestBuilder.TranslateToManifestConvention(value);
            }
            stringBuilder.Append(" message=\"$(string.").Append(str).Append(")\"");
            this.stringTab.Add(str, value);
        }
예제 #3
0
        public void AddEventParameter(Type type, string name)
        {
            if (this.numParams == 0)
            {
                this.templates.Append("  <template tid=\"").Append(this.templateName).Append("\">").AppendLine();
            }
            ManifestBuilder manifestBuilder = this;

            manifestBuilder.numParams = manifestBuilder.numParams + 1;
            this.templates.Append("   <data name=\"").Append(name).Append("\" inType=\"").Append(ManifestBuilder.GetTypeName(type)).Append("\"");
            if (type.IsEnum)
            {
                this.templates.Append(" map=\"").Append(type.Name).Append("\"");
                if (this.mapsTab == null)
                {
                    this.mapsTab = new Dictionary <string, Type>();
                }
                if (!this.mapsTab.ContainsKey(type.Name))
                {
                    this.mapsTab.Add(type.Name, type);
                }
            }
            this.templates.Append("/>").AppendLine();
        }
예제 #4
0
 public void StartEvent(string eventName, EventAttribute eventAttribute)
 {
     this.templateName = string.Concat(eventName, "Args");
     this.numParams    = 0;
     this.events.Append("  <event").Append(" symbol=\"").Append(eventName).Append("\"").Append(" value=\"").Append(eventAttribute.EventId).Append("\"").Append(" version=\"").Append(eventAttribute.Version).Append("\"").Append(" level=\"").Append(ManifestBuilder.GetLevelName(eventAttribute.Level)).Append("\"");
     this.WriteMessageAttrib(this.events, "event", eventName, eventAttribute.Message);
     if (eventAttribute.Keywords != EventKeywords.None)
     {
         ulong channelKeyword = ~this.GetChannelKeyword(eventAttribute.Channel) & (ulong)eventAttribute.Keywords;
         this.events.Append(" keywords=\"").Append(this.GetKeywords(channelKeyword, 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.Default)
     {
         this.events.Append(" channel=\"").Append(this.GetChannelName(eventAttribute.Channel, eventName)).Append("\"");
     }
 }
예제 #5
0
        private static string GetTypeName(Type type)
        {
            if (type.IsEnum)
            {
                FieldInfo[] fields   = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                string      typeName = ManifestBuilder.GetTypeName(fields[0].FieldType);
                return(typeName.Replace("win:Int", "win:UInt"));
            }
            switch (Type.GetTypeCode(type))
            {
            case TypeCode.Object:
            {
                return("win:UnicodeString");
            }

            case TypeCode.DBNull:
            case TypeCode.Char:
            case TypeCode.Decimal:
            case TypeCode.DateTime:
            case TypeCode.Object | TypeCode.DateTime:
            {
                if (type != typeof(Guid))
                {
                    throw new ArgumentException(EventSourceSR.Event_UnsupportType(type.Name));
                }
                return("win:GUID");
            }

            case TypeCode.Boolean:
            {
                return("win:Boolean");
            }

            case TypeCode.SByte:
            {
                return("win:Int8");
            }

            case TypeCode.Byte:
            {
                return("win:Uint8");
            }

            case TypeCode.Int16:
            {
                return("win:Int16");
            }

            case TypeCode.UInt16:
            {
                return("win:UInt16");
            }

            case TypeCode.Int32:
            {
                return("win:Int32");
            }

            case TypeCode.UInt32:
            {
                return("win:UInt32");
            }

            case TypeCode.Int64:
            {
                return("win:Int64");
            }

            case TypeCode.UInt64:
            {
                return("win:UInt64");
            }

            case TypeCode.Single:
            {
                return("win:Float");
            }

            case TypeCode.Double:
            {
                return("win:Double");
            }

            case TypeCode.String:
            {
                return("win:UnicodeString");
            }

            default:
            {
                if (type != typeof(Guid))
                {
                    throw new ArgumentException(EventSourceSR.Event_UnsupportType(type.Name));
                }
                return("win:GUID");
            }
            }
        }