Ejemplo n.º 1
0
        internal static STATPROPSETSTG GetStatistics(this IPropertyStorage propertyStorage)
        {
            STATPROPSETSTG statpropsetstg = default(STATPROPSETSTG);

            propertyStorage.Stat(out statpropsetstg);
            return(statpropsetstg);
        }
Ejemplo n.º 2
0
        internal PropertySet(STATPROPSETSTG stat, Property[] properties)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("properties");
            }

            _stat = stat;
            _properties.AddRange(properties);
        }
Ejemplo n.º 3
0
        internal static PropertySet InvokeInternalConstructor(Type type, STATPROPSETSTG stat, Property[] properties)
        {
            Type[]          types = new[] { typeof(STATPROPSETSTG), typeof(Property[]) };
            ConstructorInfo ctor  = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, types, null);

            if (ctor != null)
            {
                return((PropertySet)ctor.Invoke(new object[] { stat, properties }));
            }
            else
            {
                throw new System.Reflection.TargetException(String.Format("Unable for find appropriate constructor for type '{0}'", type.FullName));
            }
        }
Ejemplo n.º 4
0
 internal SummaryInformationPropertySet(STATPROPSETSTG stat, Property[] properties)
     : base(stat, properties)
 {
 }
Ejemplo n.º 5
0
 internal CustomPropertySet(STATPROPSETSTG stat, Property[] properties)
     : base(stat, properties)
 {
 }
Ejemplo n.º 6
0
        private void LoadPropertySets()
        {
            HRESULT             hr         = (int)HRESULT.E_FAIL;
            IEnumSTATPROPSETSTG enumerator = null;

            STATPROPSETSTG[] stat    = new STATPROPSETSTG[1];
            uint             fetched = 0;
            List <Guid>      fmtids  = new List <Guid>();

            // Build list of FMTID's.
            try
            {
                if (NativeMethods.Succeeded(hr = _propertySetStorage.Enum(out enumerator)))
                {
                    while (NativeMethods.Succeeded(hr = (enumerator.Next(1, stat, out fetched))) && (fetched == 1))
                    {
                        fmtids.Add(stat[0].fmtid);
                    }

                    // IPropertySetStorage.Enum() does not enumerate FMTID_UserDefinedProperties.
                    // Note that FMTID_UserDefinedProperties may not exist.
                    fmtids.Add(FormatId.UserDefinedProperties);
                }

                foreach (Guid fmtid in fmtids)
                {
                    Guid rfmtid  = fmtid;
                    uint grfMode = (uint)(STGM.READ | STGM.SHARE_EXCLUSIVE);
                    //uint grfMode = (uint)(STGM.DIRECT | STGM.READ | STGM.SHARE_DENY_WRITE);
                    IPropertyStorage propertyStorage = null;

                    try
                    {
                        if (NativeMethods.Succeeded(hr = _propertySetStorage.Open(ref rfmtid, grfMode, out propertyStorage)))
                        {
                            _propertySets.Add(PropertySet.FromIPropertyStorage(propertyStorage));
                        }
                    }
                    catch
                    {
#if DEBUG
                        System.Diagnostics.Debugger.Break();
#endif
                    }
                    finally
                    {
                        if (propertyStorage != null)
                        {
                            propertyStorage.FinalRelease();
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.FinalRelease();
                }
            }
        }