Пример #1
0
        // create
        public virtual EsfNode CreateValueNode(EsfType typeCode, bool optimize = true)
        {
            EsfNode result;

            switch (typeCode)
            {
            case EsfType.BOOL:
                result = new BoolNode();
                break;

            case EsfType.INT8:
                result = new SByteNode();
                break;

            case EsfType.INT16:
                result = new ShortNode();
                break;

            case EsfType.INT32:
                result = new IntNode();
                break;

            case EsfType.INT64:
                result = new LongNode();
                break;

            case EsfType.UINT8:
                result = new ByteNode();
                break;

            case EsfType.UINT16:
                result = new UShortNode();
                break;

            case EsfType.UINT32:
                result = new UIntNode();
                break;

            case EsfType.UINT64:
                result = new ULongNode();
                break;

            case EsfType.SINGLE:
                result = new FloatNode();
                break;

            case EsfType.DOUBLE:
                result = new DoubleNode();
                break;

            case EsfType.COORD2D:
                result = new Coordinate2DNode();
                break;

            case EsfType.COORD3D:
                result = new Coordinates3DNode();
                break;

            case EsfType.UTF16:
                result = new StringNode(ReadUtf16, WriteUtf16);
                break;

            case EsfType.ASCII:
                result = new StringNode(ReadAscii, WriteAscii);
                break;

            case EsfType.ANGLE:
                result = new UShortNode();
                break;

            //TODO confirm intended data types of types indicated by unknown enum values
            case EsfType.UNKNOWN_23:
                result = new SByteNode();
                break;

            case EsfType.UNKNOWN_24:
                result = new ShortNode();
                break;

            case EsfType.UNKNOWN_26:
                result = new Type26Node();
                break;

            default:
                throw new InvalidDataException(string.Format("Invalid type code {0:x}", typeCode));
            }
            result.TypeCode = typeCode;
            return(result);
        }