Ejemplo n.º 1
0
 private void WriteIntFlags2Content(XmlWriter writer, MetaInt32_Enum3 intValue)
 {
     if (intValue.Value != 0)
     {
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < 32; i++)
         {
             if ((intValue.Value & (1 << i)) != 0)
             {
                 if (intValue.info != null)
                 {
                     foreach (var xy in intValue.info.Entries)
                     {
                         if (xy.EntryValue == i)
                         {
                             sb.Append(' ');
                             sb.Append(GetFlagNameForHash(xy.EntryNameHash));
                         }
                     }
                 }
                 else
                 {
                     sb.Append(" flag_index_");
                     sb.Append(i);
                 }
             }
         }
         writer.WriteString(sb.ToString().Trim());
     }
 }
Ejemplo n.º 2
0
        private MetaInt32_Enum3 ReadIntFlags2(XmlNode node, int enumNameHash)
        {
            var intFlags = new MetaInt32_Enum3();

            if (enumNameHash == 0)
            {
                // TODO: Parse using Span
                var keyStrings = node.InnerText.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var x in keyStrings)
                {
                    var enumIdx = int.Parse(x.AsSpan(11), NumberStyles.Integer, CultureInfo.InvariantCulture);
                    intFlags.Value += (uint)(1 << enumIdx);
                }
            }
            else
            {
                var enumInfo = (MetaEnumXml)null;
                foreach (var x in xmlInfos.Enums)
                {
                    if (x.NameHash == enumNameHash)
                    {
                        enumInfo = x;
                    }
                }
                // TODO: Parse using Span
                var keyStrings = node.InnerText.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var x in keyStrings)
                {
                    var enumKey = GetHashForFlagName(x);
                    foreach (var y in enumInfo.Entries)
                    {
                        if (y.NameHash == enumKey)
                        {
                            intFlags.Value += (uint)(1 << y.Value);
                        }
                    }
                }
            }

            return(intFlags);
        }
 public void AssertInt32(MetaInt32_Enum3 expectedInt, MetaInt32_Enum3 actualInt)
 {
     Assert.AreEqual(expectedInt.Value, actualInt.Value);
 }