Beispiel #1
0
        /// <summary>
        /// Performs default encoding behaviour.. if the property is typed as 'prop_type_string' it's decoded with Encoding.Default, otherwise it uses Unicode (UCS16 LE)...
        /// <para>This is not always desired, but works most of the time.</para>
        /// </summary>
        /// <param name="propBag"></param>
        /// <param name="propID"></param>
        /// <returns></returns>
        public static string GetStringProperty(IPropertyObject propBag, PropId propID)
        {
            var propType = propBag.GetPropertyType(propID);

            byte[] bytes = propBag.ReadProperty(propID);

            if (propType != PropertyType.KnownValue.prop_type_wstring &&
                propType != PropertyType.KnownValue.prop_type_string)
            {
                throw new ArgumentException("Invalid Property Type");
            }

            return
                (propType == PropertyType.KnownValue.prop_type_string
                ? PropertyHelper.GetEncodedStringProperty(bytes, Encoding.UTF8)
                : PropertyHelper.GetUnicodeStringProperty(bytes));
        }
Beispiel #2
0
 public PropertyType GetPropertyType(PropId id)
 {
     return(_propBag.GetPropertyType(id));
 }