Esempio n. 1
0
        public CProperty GetProperty()
        {
            // First, read the length and value of the following property name string
            int    propNameLength = GetInt();
            string propName       = GetString(propNameLength);

            SkipPadding();

            // If this is a "None" ending type property, just return - nothing else will follow this
            if (propName == "None")
            {
                return(null);
            }

            // Get the property type string
            int    typeNameLength = GetInt();
            string typeName       = GetString(typeNameLength);

            SkipPadding();

            // Skip past the size of the following data and its padding
            GetInt();
            SkipPadding();

            // Finally, read the data based on the property type
            CProperty returnProperty;

            switch (typeName)
            {
            case "ArrayProperty":
                returnProperty = new ArrayProperty(propName, this);
                break;

            case "IntProperty":
                returnProperty = new IntProperty(propName, this);
                break;

            case "StrProperty":
                returnProperty = new StrProperty(propName, this);
                break;

            case "NameProperty":
                returnProperty = new NameProperty(propName, this);
                break;

            case "StructProperty":
                returnProperty = new StructProperty(propName, this, _outputter);
                break;

            case "BoolProperty":
                returnProperty = new BoolProperty(propName, this);
                break;

            default:
                throw new Exception($"Unexpected property type: {typeName}");
            }

            returnProperty.ParseData();
            return(returnProperty);
        }