public void Apply(ISetProperties setProperties)
 {
     int count = this.Properties.Count;
     string[] names = new string[count];
     PropVariant[] variantArray = new PropVariant[count];
     int index = 0;
     foreach (KeyValuePair<string, object> pair in this.Properties)
     {
         names[index] = pair.Key;
         variantArray[index] = new PropVariant(pair.Value);
         index++;
     }
     GCHandle handle = GCHandle.Alloc(variantArray, GCHandleType.Pinned);
     try
     {
         setProperties.SetProperties(names, handle.AddrOfPinnedObject(), count);
     }
     finally
     {
         handle.Free();
     }
     foreach (PropVariant variant in variantArray)
     {
         variant.Clear();
     }
 }
Beispiel #2
0
 /* ----------------------------------------------------------------- */
 ///
 /// Execute
 ///
 /// <summary>
 /// オプションをアーカイブ・オブジェクトに設定します。
 /// </summary>
 ///
 /// <param name="dest">アーカイブ・オブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public override void Execute(ISetProperties dest)
 {
     if (Option is SevenZipOption so)
     {
         AddCompressionMethod(so);
     }
     base.Execute(dest);
 }
 /* ----------------------------------------------------------------- */
 ///
 /// Execute
 ///
 /// <summary>
 /// オプションをアーカイブ・オブジェクトに設定します。
 /// </summary>
 ///
 /// <param name="dest">アーカイブ・オブジェクト</param>
 ///
 /* ----------------------------------------------------------------- */
 public override void Execute(ISetProperties dest)
 {
     if (Option is ZipOption zo)
     {
         AddCompressionMethod(zo);
         AddEncryptionMethod(zo);
     }
     base.Execute(dest);
 }
        /* ----------------------------------------------------------------- */
        ///
        /// Execute
        ///
        /// <summary>
        /// オプションをアーカイブ・オブジェクトに設定します。
        /// </summary>
        ///
        /// <param name="dest">アーカイブ・オブジェクト</param>
        ///
        /* ----------------------------------------------------------------- */
        public virtual void Execute(ISetProperties dest)
        {
            Debug.Assert(Option != null && dest != null);

            var src = new Dictionary <string, PropVariant>(_dic);

            if (Option.CodePage != CodePage.Oem)
            {
                src.Add("cp", PropVariant.Create((uint)Option.CodePage));
            }

            var values = CreateValues(src.Values);

            try
            {
                var k      = CreateNames(src.Keys);
                var v      = values.AddrOfPinnedObject();
                var result = dest.SetProperties(k, v, (uint)k.Length);
                Debug.Assert(result == 0);
            }
            finally { values.Free(); }
        }