Exemplo n.º 1
0
        public List <ITypedPropertyValue> ReadProperty(PropertyIdentifiersSummaryInfo propertyIdentifier, BinaryReader br)
        {
            List <ITypedPropertyValue> res = new List <ITypedPropertyValue>();
            bool isVariant         = false;
            PropertyDimensions dim = PropertyDimensions.IsScalar;

            UInt16 pVal = br.ReadUInt16();

            VTPropertyType vType = (VTPropertyType)(pVal & 0x00FF);

            if ((pVal & 0x1000) != 0)
            {
                dim = PropertyDimensions.IsVector;
            }
            else if ((pVal & 0x2000) != 0)
            {
                dim = PropertyDimensions.IsArray;
            }

            isVariant = ((pVal & 0x00FF) == 0x000C);

            br.ReadUInt16(); // Ushort Padding

            switch (dim)
            {
            case PropertyDimensions.IsVector:

                ITypedPropertyValue vectorHeader = factory.NewProperty(VTPropertyType.VT_VECTOR_HEADER, ctx);
                vectorHeader.Read(br);

                uint nItems = (uint)vectorHeader.PropertyValue;

                for (int i = 0; i < nItems; i++)
                {
                    VTPropertyType vTypeItem = VTPropertyType.VT_EMPTY;

                    if (isVariant)
                    {
                        UInt16 pValItem = br.ReadUInt16();
                        vTypeItem = (VTPropertyType)(pValItem & 0x00FF);
                        br.ReadUInt16();     // Ushort Padding
                    }
                    else
                    {
                        vTypeItem = vType;
                    }

                    var p = factory.NewProperty(vTypeItem, ctx);

                    p.Read(br);
                    res.Add(p);
                }

                break;

            default:

                //Scalar property
                ITypedPropertyValue pr = factory.NewProperty(vType, ctx);

                pr.Read(br);

                if (propertyIdentifier == PropertyIdentifiersSummaryInfo.CodePageString)
                {
                    this.ctx.CodePage = (short)pr.PropertyValue;
                }

                res.Add(pr);
                break;
            }

            return(res);
        }
Exemplo n.º 2
0
 public TypedPropertyValue(VTPropertyType vtType, bool isVariant = false)
 {
     this._VTType   = vtType;
     dim            = CheckPropertyDimensions(vtType);
     this.isVariant = isVariant;
 }