Ejemplo 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);
        }
Ejemplo n.º 2
0
        public List <ITypedPropertyValue> ReadProperty(PropertyIdentifiersSummaryInfo propertyIdentifier,
                                                       BinaryReader br)
        {
            var res = new List <ITypedPropertyValue>();
            var dim = PropertyDimensions.IsScalar;

            var pVal = br.ReadUInt16();

            var vType = (VtPropertyType)(pVal & 0x00FF);

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

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

            br.ReadUInt16(); // Ushort Padding

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (dim)
            {
            case PropertyDimensions.IsVector:

                var vectorHeader = _factory.NewProperty(VtPropertyType.VtVectorHeader, _ctx);
                vectorHeader.Read(br);

                var nItems = (uint)vectorHeader.PropertyValue;

                for (var i = 0; i < nItems; i++)
                {
                    VtPropertyType vTypeItem;

                    if (isVariant)
                    {
                        var 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;

            //Scalar property
            default:
                var pr = _factory.NewProperty(vType, _ctx);

                pr.Read(br);

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

                res.Add(pr);
                break;
            }

            return(res);
        }