protected void SetValue<T>(SignatureTag tag, IndexType type, T[] value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } var collection = new Collection<T>(value); IndexRecord record = new IndexRecord() { Header = new IndexHeader() { Count = collection.Count, Offset = 0, Tag = (uint)tag, Type = type }, Value = collection }; if (!this.Package.Signature.Records.ContainsKey(tag)) { this.Package.Signature.Records.Add(tag, record); } else { this.Package.Signature.Records[tag] = record; } }
protected void SetValue <T>(IndexTag tag, IndexType type, T[] value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } // We won't accept empty arrays; rather, we remove the key alltogether. // This brings compatibility with newer versions of RPM if (value.Length > 0) { var collection = new Collection <T>(value); IndexRecord record = new IndexRecord() { Header = new IndexHeader() { Count = collection.Count, Offset = 0, Tag = (uint)tag, Type = type }, Value = collection }; if (!this.Package.Header.Records.ContainsKey(tag)) { this.Package.Header.Records.Add(tag, record); } else { this.Package.Header.Records[tag] = record; } } else { if (this.Package.Header.Records.ContainsKey(tag)) { this.Package.Header.Records.Remove(tag); } } }
protected void SetSingleValue<T>(SignatureTag tag, IndexType type, T value) { IndexRecord record = new IndexRecord() { Header = new IndexHeader() { Count = 1, Offset = 0, Tag = (uint)tag, Type = type }, Value = value }; if (!this.Package.Signature.Records.ContainsKey(tag)) { this.Package.Signature.Records.Add(tag, record); } else { this.Package.Signature.Records[tag] = record; } }