iwantedue.OutlookStorage.GetMapiPropertyFromPropertyStream C# (CSharp) Méthode

GetMapiPropertyFromPropertyStream() private méthode

Gets the MAPI property value from the property stream in this storage.
private GetMapiPropertyFromPropertyStream ( string propIdentifier ) : object
propIdentifier string The 4 char hexadecimal prop identifier.
Résultat object
        private object GetMapiPropertyFromPropertyStream(string propIdentifier)
        {
            //if no property stream return null
            if (!this.streamStatistics.ContainsKey(OutlookStorage.PROPERTIES_STREAM))
            {
                return null;
            }

            //get the raw bytes for the property stream
            byte[] propBytes = this.GetStreamBytes(OutlookStorage.PROPERTIES_STREAM);

            //iterate over property stream in 16 byte chunks starting from end of header
            for (int i = this.propHeaderSize; i < propBytes.Length; i = i + 16)
            {
                //get property type located in the 1st and 2nd bytes as a unsigned short value
                ushort propType = BitConverter.ToUInt16(propBytes, i);

                //get property identifer located in 3nd and 4th bytes as a hexdecimal string
                byte[] propIdent = new byte[] { propBytes[i + 3], propBytes[i + 2] };
                string propIdentString = BitConverter.ToString(propIdent).Replace("-", "");

                //if this is not the property being gotten continue to next property
                if (propIdentString != propIdentifier)
                {
                    continue;
                }

                //depending on prop type use method to get property value
                switch (propType)
                {
                    case NativeMethods.PT_I2:
                        return BitConverter.ToInt16(propBytes, i + 8);

                    case NativeMethods.PT_LONG:
                        return BitConverter.ToInt32(propBytes, i + 8);

                    default:
                        throw new ApplicationException("MAPI property has an unsupported type and can not be retrieved.");
                }
            }

            //property not found return null
            return null;
        }