Exemplo n.º 1
0
 public ListDataType64(string name, int width, int pointerWidth, BaseDataType listType)
     : base(name, width, pointerWidth)
 {
     ListType = listType;
 }
Exemplo n.º 2
0
        /// <summary>
        /// creates new instance of AbstratData derived class from <c>inStream</c>
        /// inStream position should be in the beginning of data of pointer to data
        /// </summary>
        /// <param name="type">type to read</param>
        /// <param name="inStream">strem to read from</param>
        /// <param name="options">null or list of params required to read dat aof type <c>type</c></param>
        /// <returns></returns>
        public static AbstractData CreateData(BaseDataType type, BinaryReader inStream, Dictionary <string, object> options)
        {
            // check if list type
            var listDataType = type as ListDataType;

            if (listDataType != null) // list type data
            {
                return(new ListData(listDataType, inStream, options));
            }

            if (type.Name == "ref|generic")
            {
                return(new Int32Data(type, inStream, options));
            }

            // check if pointer type
            var pointerDataType = type as PointerDataType;

            if (pointerDataType != null) // pointer type data
            {
                return(new PointerData(pointerDataType, inStream, options));
            }

            // value type data
            AbstractData data;

            switch (type.Name)
            {
            case "bool":
                data = new ValueData <bool>(type, inStream, options);
                break;

            case "byte":
                data = new ValueData <byte>(type, inStream, options);
                break;

            case "short":
                data = new ValueData <short>(type, inStream, options);
                break;

            case "int":
                data = new Int32Data(type, inStream, options);
                break;

            case "uint":
                data = new ValueData <uint>(type, inStream, options);
                break;

            case "float":
                data = new ValueData <float>(type, inStream, options);
                break;

            case "long":
                data = new Int64Data(type, inStream, options);
                break;

            case "ulong":
                data = new ValueData <ulong>(type, inStream, options);
                break;

            case "string":
                data = new StringData(type, inStream, options);
                break;

            default:
                throw new Exception("Unknown value type name: " + type.Name);
            }
            return(data);
        }