示例#1
0
文件: Field.cs 项目: phbaer/Spica
        /**
         * Default constsructor for custom fields.
         * @param field An array of field parameters (package, type, name, array/size, value)
         * @param filename The name of the file in which the field is defined
         */
        public Field(Structure structure, string filename, string[] field)
            : base(filename, field[0])
        {
            this.typename = field[1];
            this.type = TypeID(field[1]);
            this.element = null;
            this.structure = structure;

            if (field[3] == null)
            {
                this.array = -1;
            }
            else if (field[3].Length == 0)
            {
                this.array = 0;
            }
            else
            {
                this.array = Int32.Parse(field[3]);
            }

            this.field_value = field[4];

            Name = field[2];

            // TODO: Default value functionality not yet implemented!
            //            DefaultValue = fi.value;
        }
示例#2
0
文件: Field.cs 项目: phbaer/Spica
        internal override void Resolve(IList<Element> elements)
        {
            // Primitive type, no need to resolve the type
            if (this.type != -1)
            {
                return;
            }

            if ((elements == null) && (this.element == null))
            {
                throw new CException("Unable to resolve field type '{0}', no viable selection of elements available", this.typename);
            }

            foreach (Element e in elements)
            {
                if (this.typename.Equals(e.Name))
                {
                    this.element = e;
                    return;
                }
            }

            throw new CException("Unable to resolve field type '{0}'", this.typename);
        }