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(); } }
private static extern int PropVariantClear(ref PropVariant pvar);
public int UpdateProperty(uint commandId, ref PropertyKey key, PropVariantRef currentValue, out PropVariant newValue) { return contentEditor.CommandManager.UpdateProperty(commandId, ref key, currentValue, out newValue); }
private object GetProperty(ItemPropId PropId) { object obj2 = null; if ((this.CachedProperties == null) || !this.CachedProperties.TryGetValue(PropId, out obj2)) { try { PropVariant variant = new PropVariant(); try { this.Context.GetProperty(this.Index, PropId, ref variant); obj2 = variant.Value; } finally { variant.Clear(); } if (this.CachedProperties == null) { this.CachedProperties = new Dictionary<ItemPropId, object>(); } this.CachedProperties[PropId] = obj2; } catch (Exception exception) { exception.Data["SevenZip_ItemPropId"] = PropId; throw; } } return obj2; }
public void GetProperty(uint index, ItemPropId propID, ref PropVariant value) { this.EnterArchiveLock(); try { this.Archive.GetProperty(index, propID, ref value); } finally { Monitor.Exit(this.ArchiveLock); } }