示例#1
0
 void WriteReaderString(TypeInfo typeInfo, string name, CodeStringBuilder builder, bool field = true)
 {
     if (typeInfo.IsPrimitive)
     {
         if (!field)
         {
             builder.AppendLine("var {0} = {1};", name, Util.CreateReaderString(typeInfo));
         }
         else
         {
             builder.AppendLine("{0} = {1};", name, Util.CreateReaderString(typeInfo));
         }
     }
     else if (typeInfo.IsEnum)
     {
         EnumInfo enumType = (EnumInfo)typeInfo;
         if (!field)
         {
             builder.AppendLine("var {0} = {1};", name, Util.CreateReaderString(enumType));
         }
         else
         {
             builder.AppendLine("{0} = {1};", name, Util.CreateReaderString(enumType));
         }
     }
     else
     {
         if (!field)
         {
             builder.AppendLine("var {0} = new {1}();", name, typeInfo.UsableType);
         }
         builder.AppendLine("{0}.Unpack(reader);", name);
     }
 }
示例#2
0
        string BuildEnumItems(XElement node, EnumInfo myInfo)
        {
            CodeStringBuilder returnText = new CodeStringBuilder(2);

            foreach (var item in node.Elements())
            {
                if (item.Name == "value" || item.Name == "mask")
                {
                    BuildEnumItem(item, returnText, myInfo);
                }
            }
            return(returnText.ToString().RemoveEndingComma());
        }
示例#3
0
 void WriteWriterString(TypeInfo typeInfo, string name, CodeStringBuilder builder)
 {
     if (typeInfo.IsPrimitive)
     {
         builder.AppendLine(Util.CreateWriterString(typeInfo, name) + ";");
     }
     else if (typeInfo.IsEnum)
     {
         EnumInfo enumType = (EnumInfo)typeInfo;
         builder.AppendLine(Util.CreateWriterString(enumType, name) + ";");
     }
     else
     {
         builder.AppendLine("{0}.Pack(writer);", name);
     }
 }
示例#4
0
        void BuildEnumItem(XElement node, CodeStringBuilder returnText, EnumInfo myInfo)
        {
            string itemValue = node.GetAttribute("value");
            string itemName  = node.GetAttribute("name");

            if (String.IsNullOrWhiteSpace(itemName))
            {
                itemName = "Unknown" + BlankCounter++;
            }
            myInfo.ValueMap.Add(itemName, itemValue);

            var itemText = node.Attribute("text");

            if (itemText != null && itemText.IsValid())
            {
                returnText.AppendLine();
                returnText.AppendSummary(itemText.Value);
            }
            returnText.AppendLine("{0} = {1},", itemName, itemValue);
        }