Ejemplo n.º 1
0
            void IEnumSTATPROPSTG.Clone(out IEnumSTATPROPSTG ppenum)
            {
                UnsafeNativeCompoundFileMethods.UnsafeNativeIEnumSTATPROPSTG enumSTATPROPSTG;

                _unsafeEnumSTATPROPSTG.Clone(out enumSTATPROPSTG);

                if (enumSTATPROPSTG != null)
                {
                    ppenum = new SafeIEnumSTATPROPSTGImplementation(enumSTATPROPSTG);
                }
                else
                {
                    ppenum = null;
                }
            }
Ejemplo n.º 2
0
            void IEnumSTATPROPSTG.Clone(out IEnumSTATPROPSTG ppenum)
            {
                SecurityHelper.DemandCompoundFileIOPermission();

                UnsafeNativeCompoundFileMethods.UnsafeNativeIEnumSTATPROPSTG enumSTATPROPSTG;

                _unsafeEnumSTATPROPSTG.Clone(out enumSTATPROPSTG);

                if (enumSTATPROPSTG != null)
                {
                    ppenum = new SafeIEnumSTATPROPSTGImplementation(enumSTATPROPSTG);
                }
                else
                {
                    ppenum = null;
                }
            }
Ejemplo n.º 3
0
            // Methods
            internal StatPropStgCollection(IPropertyStorage propertyStorage)
            {
                StatPropStg Stat;

                IEnumSTATPROPSTG oEnum = propertyStorage.Enum();

Label_0024:
                var fetched = 0;

                if (oEnum.Next(1, out Stat, out fetched) == 0)
                {
                    base.InnerList.Add(Stat);
                    goto Label_0024;
                }
                Marshal.ReleaseComObject(oEnum);
                oEnum = null;
            }
Ejemplo n.º 4
0
            void IPropertyStorage.Enum(
                out IEnumSTATPROPSTG ppenum
                )
            {
#if Using_SafeIPropertyStorageImplementation_Enum
                UnsafeNativeCompoundFileMethods.UnsafeNativeIEnumSTATPROPSTG unsafeEnumSTATPROPSTG;

                _unsafePropertyStorage.Enum(
                    out unsafeEnumSTATPROPSTG
                    );

                if (unsafeEnumSTATPROPSTG != null)
                {
                    ppenum = new SafeIEnumSTATPROPSTGImplementation(unsafeEnumSTATPROPSTG);
                }
                else
#endif
                ppenum = null;
            }
Ejemplo n.º 5
0
        public void Clear()
        {
            StatPropStg StatProp;

            IEnumSTATPROPSTG oEnum = this.m_IPropStgObj.Enum();

Label_003E:
            var fetched = 0;

            if (oEnum.Next(1, out StatProp, out fetched) == 0)
            {
                if (StatProp.PropName == null)
                {
                    this.Remove(StatProp.PropID);
                }
                else
                {
                    this.Remove(StatProp.PropName);
                }
                goto Label_003E;
            }
            Marshal.ReleaseComObject(oEnum);
        }
Ejemplo n.º 6
0
        internal static PropertySet FromIPropertyStorage(IPropertyStorage propertyStorage)
        {
            if (propertyStorage == null)
            {
                throw new ArgumentNullException("propertyStorage");
            }

            HRESULT        hr          = HRESULT.E_FAIL;
            PropertySet    propertySet = null;
            STATPROPSETSTG stat;

            propertyStorage.Stat(out stat);

            IEnumSTATPROPSTG enumerator = null;

            List <Property> properties = new List <Property>();

            try
            {
                if (NativeMethods.Succeeded(hr = propertyStorage.Enum(out enumerator)))
                {
                    STATPROPSTG[] sps     = new STATPROPSTG[] { default(STATPROPSTG) };
                    uint          fetched = 0;

                    while ((enumerator.Next(1, sps, out fetched) == HRESULT.S_OK) && (fetched == 1))
                    {
                        string      name;
                        PROPVARIANT propvar = default(PROPVARIANT);

                        try
                        {
                            propertyStorage.GetPropertyName(sps[0].propid, out name);
                            sps[0].lpwstrName = name;
                            propertyStorage.GetProperty(sps[0].propid, out propvar);
                            properties.Add(new Property(sps[0], propvar.Value));
                        }
                        catch
                        {
                        }
                        finally
                        {
                            propvar.Clear();
                        }
                    }
                }
            }
            catch
            {
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.FinalRelease();
                }
            }

            Type type = System.Reflection.Assembly.GetExecutingAssembly().GetPropertySetType(stat.fmtid);

            if (type == null)
            {
                // In this case, we did not find a strongly typed property set.
                type = typeof(PropertySet);
            }

            propertySet      = PropertySet.InvokeInternalConstructor(type, stat, properties.ToArray());
            propertySet.Name = type.GetPropertySetName();

            return(propertySet);
        }
Ejemplo n.º 7
0
            void IEnumSTATPROPSTG.Clone(out IEnumSTATPROPSTG ppenum)
            {
                SecurityHelper.DemandCompoundFileIOPermission();

                UnsafeNativeCompoundFileMethods.UnsafeNativeIEnumSTATPROPSTG enumSTATPROPSTG;

                _unsafeEnumSTATPROPSTG.Clone(out enumSTATPROPSTG);

                if (enumSTATPROPSTG != null)
                    ppenum = new SafeIEnumSTATPROPSTGImplementation(enumSTATPROPSTG);
                else
                    ppenum = null;
            }
Ejemplo n.º 8
0
            void IPropertyStorage.Enum(
                out IEnumSTATPROPSTG ppenum
                )
            {
                SecurityHelper.DemandCompoundFileIOPermission();

#if Using_SafeIPropertyStorageImplementation_Enum                

                UnsafeNativeCompoundFileMethods.UnsafeNativeIEnumSTATPROPSTG unsafeEnumSTATPROPSTG;

                _unsafePropertyStorage.Enum(
                    out unsafeEnumSTATPROPSTG
                    );

                if (unsafeEnumSTATPROPSTG != null)
                    ppenum = new SafeIEnumSTATPROPSTGImplementation(unsafeEnumSTATPROPSTG);
                else
#endif                    
                    ppenum = null;
            }
Ejemplo n.º 9
0
 internal static void FinalRelease(this IEnumSTATPROPSTG enumerator)
 {
     Marshal.FinalReleaseComObject(enumerator);
 }