예제 #1
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");
            }
            }
        }
예제 #2
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();
        }