A layout for an enum in a tag layout.
コード例 #1
0
            private string BuildEnum(EnumLayout layout, TextWriter writer)
            {
                var enumName        = MakeName(layout.Name + " Value");
                var valueNameCounts = new Dictionary <string, int>();

                writer.WriteLine("{0}public enum {1} : {2}", _indent, enumName, GetTypeName(layout.UnderlyingType));
                writer.WriteLine("{0}{{", _indent);
                SetIndent(_indentLevel + 1);
                var nextValue = 0;

                foreach (var val in layout.Values)
                {
                    if (val.Value == nextValue)
                    {
                        writer.WriteLine("{0}{1},", _indent, MakeName(val.Name, valueNameCounts));
                    }
                    else
                    {
                        writer.WriteLine("{0}{1} = {2},", _indent, MakeName(val.Name, valueNameCounts), val.Value);
                    }
                    nextValue = val.Value + 1;
                }
                SetIndent(_indentLevel - 1);
                writer.WriteLine("{0}}}", _indent);
                return(enumName);
            }
コード例 #2
0
        private void ReadOptions(XmlReader reader, string name, BasicFieldType type)
        {
            XmlReader subtree = reader.ReadSubtree();

            var enumLayout = new EnumLayout(name, type);

            subtree.ReadStartElement();
            while (subtree.ReadToNextSibling("option"))
            {
                enumLayout.Add(ReadOption(subtree));
            }

            _results.Layout.Add(new EnumTagLayoutField(name, enumLayout));
        }
コード例 #3
0
 private string BuildEnum(EnumLayout layout, TextWriter writer)
 {
     var enumName = MakeName(layout.Name + " Value");
     var valueNameCounts = new Dictionary<string, int>();
     writer.WriteLine("{0}public enum {1} : {2}", _indent, enumName, GetTypeName(layout.UnderlyingType));
     writer.WriteLine("{0}{{", _indent);
     SetIndent(_indentLevel + 1);
     var nextValue = 0;
     foreach (var val in layout.Values)
     {
         if (val.Value == nextValue)
             writer.WriteLine("{0}{1},", _indent, MakeName(val.Name, valueNameCounts));
         else
             writer.WriteLine("{0}{1} = {2},", _indent, MakeName(val.Name, valueNameCounts), val.Value);
         nextValue = val.Value + 1;
     }
     SetIndent(_indentLevel - 1);
     writer.WriteLine("{0}}}", _indent);
     return enumName;
 }
コード例 #4
0
        /*private static void ReadBit(XmlReader reader)
        {
            string name = "Unknown";

            if (reader.MoveToAttribute("name"))
                name = reader.Value;
            if (!reader.MoveToAttribute("index"))
                throw new ArgumentException("Bit definitions must have an index." + PositionInfo(reader));
            int index = ParseInt(reader.Value);

            layout.VisitBit(name, index);
        }*/
        private void ReadOptions(XmlReader reader, string name, BasicFieldType type)
        {
            XmlReader subtree = reader.ReadSubtree();

            var enumLayout = new EnumLayout(name, type);
            subtree.ReadStartElement();
            while (subtree.ReadToNextSibling("option"))
                enumLayout.Add(ReadOption(subtree));

            _results.Layout.Add(new EnumTagLayoutField(name, enumLayout));
        }
コード例 #5
0
 public EnumTagLayoutField(string name, EnumLayout layout)
     : base(name)
 {
     Layout = layout;
 }
コード例 #6
0
 public EnumTagLayoutField(string name, EnumLayout layout)
     : base(name)
 {
     Layout = layout;
 }