/// <summary> /// Adds <paramref name="field"/> to this <see cref="BroRecord"/>. /// </summary> /// <param name="field">The <see cref="BroField"/> to add to this <see cref="BroRecord"/>.</param> /// <returns><c>true</c> if successful; otherwise, <c>false</c>.</returns> /// <exception cref="ArgumentNullException">Cannot add a <c>null</c> <see cref="BroField"/>.</exception> /// <exception cref="ObjectDisposedException">Cannot add item, <see cref="BroRecord"/> is disposed.</exception> public bool Add(BroField field) { if ((object)field == null) { throw new ArgumentNullException("field"); } if (m_recordPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot add value, Bro record is disposed."); } return(field.ExecuteWithFixedPtr(ptr => BroApi.bro_record_add_val(m_recordPtr, field.Name == string.Empty ? null : field.Name, field.Type, field.TypeName, ptr) != 0)); }
internal BroRecord(IntPtr sourceRecordPtr) #endif : this() { if (sourceRecordPtr.IsInvalid()) { return; } int length = BroApi.bro_record_get_length(sourceRecordPtr); for (int i = 0; i < length; i++) { BroType type = BroType.Unknown; IntPtr value = BroApi.bro_record_get_nth_val(sourceRecordPtr, i, ref type); string name = Marshal.PtrToStringAnsi(BroApi.bro_record_get_nth_name(sourceRecordPtr, i)); BroApi.bro_record_add_val(m_recordPtr, name, type, null, value); } }