Exemplo n.º 1
0
 /// <summary>
 /// Gets a PropColumn capable of reading/writing a property of the given
 /// DataType
 /// </summary>
 private PropertyMaps.Handler.PropColumn GetColumn(DataType dataType, string propName
                                                   , int dataSize)
 {
     if (IsPseudoGuidColumn(dataType, propName, dataSize))
     {
         dataType = DataType.GUID;
     }
     PropertyMaps.Handler.PropColumn col = _columns.Get(dataType);
     if (col == null)
     {
         // translate long value types into simple types
         DataType colType = dataType;
         if (dataType == DataType.MEMO)
         {
             colType = DataType.TEXT;
         }
         else
         {
             if (dataType == DataType.OLE)
             {
                 colType = DataType.BINARY;
             }
         }
         // create column with ability to read/write the given data type
         col = ((colType == DataType.BOOLEAN) ? new PropertyMaps.Handler.BooleanPropColumn
                    (this) : new PropertyMaps.Handler.PropColumn(this));
         col.SetType(colType);
         if (col.IsVariableLength())
         {
             col.SetLength((short)DataTypeProperties.Get(colType).maxSize.Value);
         }
     }
     return(col);
 }
Exemplo n.º 2
0
            /// <returns>
            /// the PropertyMap created from the values parsed from the given
            /// data chunk combined with the given property names
            /// </returns>
            /// <exception cref="System.IO.IOException"></exception>
            private PropertyMap ReadPropertyValues(ByteBuffer bbBlock, IList <string> propNames
                                                   , short blockType)
            {
                string mapName = DEFAULT_NAME;

                if (bbBlock.HasRemaining())
                {
                    // read the map name, if any
                    int nameBlockLen = bbBlock.GetInt();
                    int endPos       = bbBlock.Position() + nameBlockLen - 4;
                    if (nameBlockLen > 6)
                    {
                        mapName = ReadPropName(bbBlock);
                    }
                    bbBlock.Position(endPos);
                }
                PropertyMap map = new PropertyMap(mapName, blockType);

                // read the values
                while (bbBlock.HasRemaining())
                {
                    int      valLen   = bbBlock.GetShort();
                    int      endPos   = bbBlock.Position() + valLen - 2;
                    byte     flag     = bbBlock.Get();
                    DataType dataType = DataTypeUtil.FromByte(bbBlock.Get());
                    int      nameIdx  = bbBlock.GetShort();
                    int      dataSize = bbBlock.GetShort();
                    string   propName = propNames[nameIdx];
                    PropertyMaps.Handler.PropColumn col = GetColumn(dataType, propName, dataSize);
                    byte[] data = new byte[dataSize];
                    bbBlock.Get(data);
                    object value = col.Read(data);
                    map.Put(propName, dataType, flag, value);
                    bbBlock.Position(endPos);
                }
                return(map);
            }