internal BroTable(IntPtr sourceTablePtr) #endif : this() { if (sourceTablePtr.IsInvalid()) { return; } BroType keyType = BroType.Unknown; BroType valueType = BroType.Unknown; BroApi.bro_table_get_types(sourceTablePtr, ref keyType, ref valueType); BroApi.bro_table_foreach(sourceTablePtr, (key, value, userData) => { try { BroApi.bro_table_insert(m_tablePtr, keyType, key, valueType, value); return(~0); } catch { return(0); } }, IntPtr.Zero); }
private static BroValue ConvertBroPortToType(BroPort value, BroType type) { ulong number = value.Number; switch (type) { case BroType.Bool: return(new BroValue(Convert.ToInt32(number) == 0 ? 0 : ~0, type)); case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: return(new BroValue(number, type)); case BroType.Double: case BroType.Time: case BroType.Interval: return(new BroValue(Convert.ToDouble(number), type)); case BroType.String: return(new BroValue(value.ToString(), type)); } return(null); }
// Gets current table as a Dictionary<BroValue, BroValue> private Dictionary <BroValue, BroValue> GetDictionary() { if (m_tablePtr.IsInvalid()) { throw new ObjectDisposedException("Cannot execute dictionary operation, Bro table is disposed."); } Dictionary <BroValue, BroValue> dictionary = new Dictionary <BroValue, BroValue>(); BroType keyType = BroType.Unknown; BroType valueType = BroType.Unknown; BroApi.bro_table_get_types(m_tablePtr, ref keyType, ref valueType); BroApi.bro_table_foreach(m_tablePtr, (key, value, userData) => { try { dictionary.Add(BroValue.CreateFromPtr(key, keyType), BroValue.CreateFromPtr(value, valueType)); return(~0); } catch { return(0); } }, IntPtr.Zero); return(dictionary); }
// Gets current set as a HashSet<BroValue> private HashSet <BroValue> GetHashSet() { if (m_setPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot execute set operation, Bro set is disposed."); } HashSet <BroValue> set = new HashSet <BroValue>(); BroType type = this.Type; BroApi.bro_set_foreach(m_setPtr, (value, userData) => { try { set.Add(BroValue.CreateFromPtr(value, type)); return(~0); } catch { return(0); } }, IntPtr.Zero); return(set); }
/// <summary> /// Converts this <see cref="BroSet"/> into a <see cref="List{BroValue}"/>. /// </summary> /// <returns>Current <see cref="BroSet"/> as a <see cref="List{BroValue}"/>.</returns> /// <exception cref="ObjectDisposedException">Cannot get list, <see cref="BroSet"/> is disposed.</exception> public List <BroValue> ToList() { if (m_setPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot get list, Bro set is disposed."); } List <BroValue> list = new List <BroValue>(Count); BroType type = this.Type; BroApi.bro_set_foreach(m_setPtr, (value, userData) => { try { list.Add(BroValue.CreateFromPtr(value, type)); return(~0); } catch { return(0); } }, IntPtr.Zero); return(list); }
internal BroSet(IntPtr sourceSetPtr) #endif : this() { if (sourceSetPtr.IsInvalid()) { return; } BroType type = BroType.Unknown; BroApi.bro_set_get_type(sourceSetPtr, ref type); BroApi.bro_set_foreach(sourceSetPtr, (value, userData) => { try { BroApi.bro_set_insert(m_setPtr, type, value); return(~0); } catch { return(0); } }, IntPtr.Zero); }
private static BroValue ConvertBroAddressToType(BroAddress value, BroType type) { if (type == BroType.String) { return(new BroValue(value.ToString(), type)); } return(null); }
private static BroValue ConvertBroTableToType(BroTable value, BroType type) { if ((object)value != null && type == BroType.Set) { return(new BroValue((BroSet)value, type)); } return(null); }
private static BroValue ConvertBroStringToType(BroString value, BroType type) { string str = value; if ((object)str != null) { switch (type) { case BroType.Bool: int parsedInt; if (int.TryParse(str, out parsedInt)) { return(new BroValue(parsedInt == 0 ? 0 : ~0, type)); } bool parsedBool; if (bool.TryParse(str, out parsedBool)) { return(new BroValue(parsedBool ? ~0 : 0, type)); } break; case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: ulong parsedULong; if (ulong.TryParse(str, out parsedULong)) { return(new BroValue(parsedULong, type)); } break; case BroType.Double: case BroType.Time: case BroType.Interval: double parsedDouble; if (double.TryParse(str, out parsedDouble)) { return(new BroValue(parsedDouble, type)); } break; case BroType.IpAddr: return(new BroValue(new BroAddress(str), type)); } } return(null); }
/// <summary> /// Attempts to get a new <see cref="BroValue"/> based on the provided <paramref name="value"/> converted to the specified <paramref name="type"/>. /// </summary> /// <param name="value"><see cref="BroValue"/> to convert.</param> /// <param name="type"><see cref="BroType"/> to convert to.</param> /// <returns><see cref="BroValue"/> converted to <paramref name="type"/> if successful; otherwise, <c>null</c>.</returns> /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception> public static BroValue ConvertToType(this BroValue value, BroType type) { if ((object)value == null) { throw new ArgumentNullException("value"); } if (value.Type == type) { return(value); } switch (value.Type) { case BroType.Bool: return(ConvertIntToType(value.GetValueAsInt(), type)); case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: return(ConvertULongToType(value.GetValueAsULong(), type)); case BroType.Double: case BroType.Time: case BroType.Interval: return(ConvertDoubleToType(value.GetValueAsDouble(), type)); case BroType.Port: return(ConvertBroPortToType(value.GetValueAsBroPort(), type)); case BroType.IpAddr: return(ConvertBroAddressToType(value.GetValueAsBroAddress(), type)); case BroType.Subnet: return(ConvertBroSubnetToType(value.GetValueAsBroSubnet(), type)); case BroType.String: return(ConvertBroStringToType(value.Value as BroString, type)); case BroType.Table: return(ConvertBroTableToType(value.Value as BroTable, type)); case BroType.List: case BroType.Record: return(ConvertBroRecordToType(value.Value as BroRecord, type)); case BroType.Vector: return(ConvertBroVectorToType(value.Value as BroVector, type)); case BroType.Set: return(ConvertBroSetToType(value.Value as BroSet, type)); } return(null); }
/// <summary> /// Creates a new <see cref="BroField"/> from the provided <paramref name="value"/>, <paramref name="type"/> and specified field <paramref name="name"/>. /// </summary> /// <param name="value">Value of <see cref="BroValue"/>.</param> /// <param name="type"><see cref="BroType"/> of <see cref="BroValue"/>.</param> /// <param name="name">The field name for the <see cref="BroField"/>, can be empty string for <see cref="BroType.List">BroType.List</see> source.</param> /// <param name="typeName">Optional name of specialized type of <paramref name="value"/>.</param> /// <remarks> /// Field <paramref name="name"/> is optional when using field with a <see cref="BroRecord"/> implemented as a <see cref="BroType.List">BroType.List</see>. /// </remarks> /// <exception cref="NotSupportedException">Type is currently unsupported in Bro.</exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> public BroField(object value, BroType type, string name = "", string typeName = null) : base(value, type, typeName) { if ((object)name == null) { throw new ArgumentNullException("name"); } m_name = name; }
private static BroValue ConvertBroSubnetToType(BroSubnet value, BroType type) { switch (type) { case BroType.String: return(new BroValue(value.ToString(), type)); case BroType.IpAddr: return(new BroValue((BroAddress)value, type)); } return(null); }
/// <summary> /// Gets or sets the <see cref="BroValue"/> with the specified <paramref name="key"/> of <paramref name="keyType"/>. /// </summary> /// <param name="key">The <see cref="BroValue"/> key of the element to get or set.</param> /// <param name="keyType">The <see cref="BroType"/> of the <paramref name="key"/>.</param> /// <param name="keyTypeName">Optional name of specialized type of <paramref name="key"/>.</param> /// <returns> /// The <see cref="BroValue"/> with the specified <paramref name="key"/> if successful; otherwise, <c>null</c>. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception> /// <exception cref="ObjectDisposedException">Cannot get or add key/value pair, <see cref="BroTable"/> is disposed.</exception> /// <exception cref="InvalidOperationException">Failed to add <see cref="BroValue"/> for the specified <paramref name="key"/>.</exception> public BroValue this[object key, BroType keyType, string keyTypeName = null] { get { return(this[new BroValue(key, keyType, keyTypeName)]); } set { if (!Add(new BroValue(key, keyType, keyTypeName), value)) { throw new InvalidOperationException(string.Format("Failed to add value for key \"{0}\".", key)); } } }
/// <summary> /// Determines if <see cref="BroType"/> is an <see cref="IEnumerable"/> type. /// </summary> /// <param name="type">Bro type to test.</param> /// <returns><c>true</c> if Bro <paramref name="type"/> is an <see cref="IEnumerable"/> type; otherwise, <c>false</c>.</returns> public static bool IsEnumerableType(this BroType type) { switch (type) { case BroType.Table: case BroType.List: case BroType.Record: case BroType.Vector: case BroType.Set: return(true); } return(false); }
/// <summary> /// Determines if <see cref="BroType"/> is a reference-type (from perspective of BroccoliSharp library not Broccoli API). /// </summary> /// <param name="type">Bro type to test.</param> /// <returns><c>true</c> if Bro <paramref name="type"/> is a reference-type; otherwise, <c>false</c>.</returns> /// <remarks> /// Reference types in BroccoliSharp implement <see cref="IDisposable"/>. /// </remarks> public static bool IsReferenceType(this BroType type) { switch (type) { case BroType.String: // Reference-type BroString class wraps bro_string structure case BroType.Table: case BroType.List: case BroType.Record: case BroType.Vector: case BroType.Packet: case BroType.Set: return(true); } return(false); }
/// <summary> /// Determines if <see cref="BroType"/> is a currently unsupported type. /// </summary> /// <param name="type">Bro type to test.</param> /// <returns><c>true</c> if Bro <paramref name="type"/> is an unsupported type; otherwise, <c>false</c>.</returns> public static bool IsUnsupportedType(this BroType type) { switch (type) { case BroType.Pattern: case BroType.Timer: case BroType.Any: case BroType.Union: case BroType.Func: case BroType.File: case BroType.Error: return(true); } return(false); }
private static BroValue ConvertBroSetToType(BroSet value, BroType type) { if ((object)value != null) { switch (type) { case BroType.List: case BroType.Record: return(new BroValue(new BroRecord(value.Select(val => new BroField(val))), type)); case BroType.Vector: return(new BroValue(new BroVector(value), type)); } } return(null); }
internal BroVector(IntPtr sourceVectorPtr) #endif : this() { if (sourceVectorPtr.IsInvalid()) { return; } int length = BroApi.bro_vector_get_length(sourceVectorPtr); for (int i = 0; i < length; i++) { BroType type = BroType.Unknown; IntPtr value = BroApi.bro_vector_get_nth_val(sourceVectorPtr, i, ref type); BroApi.bro_vector_add_val(m_vectorPtr, type, null, value); } }
/// <summary> /// Copies the elements of this <see cref="BroTable"/> to an <see cref="Array"/>, starting at a particular <see cref="Array"/> index. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the elements copied from <see cref="BroTable"/>. The <see cref="Array"/> must have zero-based indexing.</param> /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param> /// <exception cref="ArgumentNullException"><paramref name="array"/> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.</exception> /// <exception cref="ArgumentException">The number of elements in the source <see cref="BroTable"/> is greater than the available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.</exception> /// <exception cref="ObjectDisposedException">Cannot copy to array, <see cref="BroTable"/> is disposed.</exception> public void CopyTo(KeyValuePair <BroValue, BroValue>[] array, int arrayIndex) { if ((object)array == null) { throw new ArgumentNullException("array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex"); } if (Count > array.Length - arrayIndex) { throw new ArgumentException("Not enough available space in destination array starting from specified array index to hold all source elements."); } if (m_tablePtr.IsInvalid()) { throw new ObjectDisposedException("Cannot copy to array, Bro table is disposed."); } BroType keyType = BroType.Unknown; BroType valueType = BroType.Unknown; int i = 0; BroApi.bro_table_get_types(m_tablePtr, ref keyType, ref valueType); BroApi.bro_table_foreach(m_tablePtr, (key, value, userData) => { try { array[arrayIndex + i++] = new KeyValuePair <BroValue, BroValue>(BroValue.CreateFromPtr(key, keyType), BroValue.CreateFromPtr(value, valueType)); return(~0); } catch { return(0); } }, IntPtr.Zero); }
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); } }
/// <summary> /// Gets or sets the <see cref="BroField"/> at the specified <paramref name="index"/>. /// </summary> /// <returns> /// The <see cref="BroField"/> at the specified <paramref name="index"/>, or <c>null</c> if there was an issue retrieving value. /// </returns> /// <param name="index">The zero-based index of the element to get or set.</param> /// <exception cref="ObjectDisposedException">Cannot get or set <see cref="BroField"/>, Bro record is disposed.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in this <see cref="BroRecord"/>.</exception> /// <exception cref="ArgumentNullException">Cannot set a <c>null</c> <see cref="BroField"/>.</exception> /// <exception cref="InvalidOperationException">Failed to update <see cref="BroField"/> at <paramref name="index"/>.</exception> public BroField this[int index] { get { if (m_recordPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot get field, Bro record is disposed."); } if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index"); } BroType type = BroType.Unknown; IntPtr valuePtr = BroApi.bro_record_get_nth_val(m_recordPtr, index, ref type); string name = Marshal.PtrToStringAnsi(BroApi.bro_record_get_nth_name(m_recordPtr, index)); return(new BroField(BroValue.CreateFromPtr(valuePtr, type), name)); } set { if (m_recordPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot set field, Bro record is disposed."); } if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index"); } if ((object)value == null) { throw new ArgumentNullException("value"); } if (value.ExecuteWithFixedPtr(ptr => BroApi.bro_record_set_nth_val(m_recordPtr, index, value.Type, value.TypeName, ptr) == 0)) { throw new InvalidOperationException(string.Format("Failed to update field at index {0}.", index)); } } }
/// <summary> /// Gets or sets the <see cref="BroValue"/> for the specified field <paramref name="name"/>. /// </summary> /// <returns> /// The <see cref="BroField"/> with the specified field name, or <c>null</c> if there was an issue retrieving value. /// </returns> /// <param name="name">Then name of the <see cref="BroField"/> to get or set.</param> /// <exception cref="ObjectDisposedException">Cannot get or set <see cref="BroField"/>, Bro record is disposed.</exception> /// <exception cref="ArgumentNullException"><paramref name="name"/> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">Cannot set a <c>null</c> <see cref="BroField"/>.</exception> /// <exception cref="InvalidOperationException">Failed to update <see cref="BroField"/> with <paramref name="name"/>.</exception> public BroValue this[string name] { get { if (m_recordPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot get field, Bro record is disposed."); } if ((object)name == null) { throw new ArgumentNullException("name"); } BroType type = BroType.Unknown; IntPtr valuePtr = BroApi.bro_record_get_named_val(m_recordPtr, name, ref type); return(new BroField(BroValue.CreateFromPtr(valuePtr, type), name)); } set { if (m_recordPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot set field, Bro record is disposed."); } if ((object)name == null) { throw new ArgumentNullException("name"); } if ((object)value == null) { throw new ArgumentNullException("value"); } if (value.ExecuteWithFixedPtr(ptr => BroApi.bro_record_set_named_val(m_recordPtr, name, value.Type, value.TypeName, ptr) == 0)) { throw new InvalidOperationException(string.Format("Failed to update field with name \"{0}\".", name)); } } }
/// <summary> /// Gets or sets the <see cref="BroValue"/> at the specified <paramref name="index"/>. /// </summary> /// <returns> /// The <see cref="BroValue"/> at the specified <paramref name="index"/>, or <c>null</c> if there was an issue retrieving value. /// </returns> /// <param name="index">The zero-based index of the element to get or set.</param> /// <exception cref="ObjectDisposedException">Cannot get or set <see cref="BroValue"/>, Bro vector is disposed.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in this <see cref="BroVector"/>.</exception> /// <exception cref="ArgumentNullException">Cannot set a <c>null</c> <see cref="BroValue"/>.</exception> /// <exception cref="InvalidOperationException">Failed to update <see cref="BroValue"/> at <paramref name="index"/>.</exception> public BroValue this[int index] { get { if (m_vectorPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot get value, Bro vector is disposed."); } if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index"); } BroType type = BroType.Unknown; IntPtr valuePtr = BroApi.bro_vector_get_nth_val(m_vectorPtr, index, ref type); return(BroValue.CreateFromPtr(valuePtr, type)); } set { if (m_vectorPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot set value, Bro vector is disposed."); } if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index"); } if ((object)value == null) { throw new ArgumentNullException("value"); } if (value.ExecuteWithFixedPtr(ptr => BroApi.bro_vector_set_nth_val(m_vectorPtr, index, value.Type, value.TypeName, ptr) == 0)) { throw new InvalidOperationException(string.Format("Failed to update value at index {0}.", index)); } } }
/// <summary> /// Determines if <see cref="BroType"/> is a value-type (from perspective of BroccoliSharp library not Broccoli API). /// </summary> /// <param name="type">Bro type to test.</param> /// <returns><c>true</c> if Bro <paramref name="type"/> is a value-type; otherwise, <c>false</c>.</returns> public static bool IsValueType(this BroType type) { switch (type) { case BroType.Bool: case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: case BroType.Double: case BroType.Time: case BroType.Interval: case BroType.Port: // Value-type BroPort structure wraps bro_port structure case BroType.IpAddr: // Value-type BroAddress structure wraps bro_addr structure case BroType.Subnet: // Value-type BroSubnet structure wraps bro_subnet structure return(true); } return(false); }
private static BroValue ConvertIntToType(int value, BroType type) { switch (type) { case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: return(new BroValue(Convert.ToUInt64(value), type)); case BroType.Double: case BroType.Time: case BroType.Interval: return(new BroValue(Convert.ToDouble(value), type)); case BroType.String: return(new BroValue(value.ToString(), type)); } return(null); }
/// <summary> /// Copies the elements of this <see cref="BroSet"/> to an <see cref="Array"/>, starting at a particular <see cref="Array"/> index. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the elements copied from <see cref="BroSet"/>. The <see cref="Array"/> must have zero-based indexing.</param> /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param> /// <exception cref="ArgumentNullException"><paramref name="array"/> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.</exception> /// <exception cref="ArgumentException">The number of elements in the source <see cref="BroSet"/> is greater than the available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.</exception> /// <exception cref="ObjectDisposedException">Cannot copy to array, <see cref="BroSet"/> is disposed.</exception> public void CopyTo(BroValue[] array, int arrayIndex) { if ((object)array == null) { throw new ArgumentNullException("array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex"); } if (Count > array.Length - arrayIndex) { throw new ArgumentException("Not enough available space in destination array starting from specified array index to hold all source elements."); } if (m_setPtr.IsInvalid()) { throw new ObjectDisposedException("Cannot copy to array, Bro set is disposed."); } BroType type = this.Type; int i = 0; BroApi.bro_set_foreach(m_setPtr, (value, userData) => { try { array[arrayIndex + i++] = BroValue.CreateFromPtr(value, type); return(~0); } catch { return(0); } }, IntPtr.Zero); }
private static BroValue ConvertDoubleToType(double value, BroType type) { switch (type) { case BroType.Bool: return(new BroValue(Convert.ToInt32(value) == 0 ? 0 : ~0, type)); case BroType.Int: case BroType.Count: case BroType.Counter: case BroType.Enum: return(new BroValue(Convert.ToUInt64(value), type)); case BroType.Double: case BroType.Time: case BroType.Interval: return(new BroValue(value, type)); case BroType.String: return(new BroValue(value.ToString(), type)); } return(null); }
/// <summary> /// Inserts <paramref name="value"/> of <paramref name="type"/> in this <see cref="BroRecord"/> at the specified <paramref name="index"/> with specified <paramref name="fieldName"/>. /// </summary> /// <param name="index">The zero-based index at which <paramref name="value"/> should be inserted.</param> /// <param name="value">The value to insert into this <see cref="BroRecord"/> as a field.</param> /// <param name="type">The <see cref="BroType"/> of the <paramref name="value"/>.</param> /// <param name="fieldName">Name of field to add to record, can be empty string for <see cref="BroType.List">BroType.List</see> source.</param> /// <param name="typeName">Optional name of specialized type of <paramref name="value"/>.</param> /// <remarks> /// This is not a native Bro record operation. Function will perform expected task, but for large data sets operation may be expensive. /// </remarks> /// <exception cref="ObjectDisposedException">Cannot execute list operation, <see cref="BroRecord"/> is disposed.</exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in this <see cref="BroRecord"/>.</exception> public void Insert(int index, object value, BroType type, string fieldName = "", string typeName = null) { Insert(index, new BroField(value, type, fieldName, typeName)); }
/// <summary> /// Adds new <paramref name="value"/> of <paramref name="type"/> to this <see cref="BroRecord"/> with specified <paramref name="fieldName"/>. /// </summary> /// <param name="value">The value to add to record as a field.</param> /// <param name="type">The <see cref="BroType"/> of the <paramref name="value"/>.</param> /// <param name="fieldName">Name of field to add to record, can be empty string for <see cref="BroType.List">BroType.List</see> source.</param> /// <param name="typeName">Optional name of specialized type of <paramref name="value"/>.</param> /// <returns><c>true</c> if successful; otherwise, <c>false</c>.</returns> /// <remarks> /// Field name is optional when using Bro record as a <see cref="BroType.List">BroType.List</see>. /// </remarks> /// <exception cref="ObjectDisposedException">Cannot add item, <see cref="BroRecord"/> is disposed.</exception> public bool Add(object value, BroType type, string fieldName = "", string typeName = null) { return(Add(new BroField(value, type, fieldName, typeName))); }
/// <summary> /// Adds a new column, with no initial value, to this <see cref="BroRecord"/> with the specified <paramref name="fieldName"/> and <paramref name="type"/>. /// </summary> /// <param name="fieldName">Name of field to add to record.</param> /// <param name="type">The <see cref="BroType"/> of the new field.</param> /// <param name="typeName">Optional name of specialized type of for the field.</param> /// <returns><c>true</c> if successful; otherwise, <c>false</c>.</returns> /// <remarks> /// You can use this method to define a new column for the <see cref="BroRecord"/> without assigning an initial value. /// </remarks> /// <exception cref="ObjectDisposedException">Cannot add item, <see cref="BroRecord"/> is disposed.</exception> public bool Add(string fieldName, BroType type, string typeName = null) { return(Add(new BroField(null, type, fieldName, typeName))); }