/// <inheritdoc /> public FieldValueUpdate([NotNull] WireReadyBitArray fieldValueUpdateMask, [NotNull] int[] fieldValueUpdates) { //We shouldn't send an a field value update if there are no fields to even update. It's pointless bandwidth wasted if (fieldValueUpdates == null) { throw new ArgumentNullException(nameof(fieldValueUpdates)); } //if(fieldValueUpdates.Length == 0) throw new ArgumentException("Value cannot be an empty collection.", nameof(fieldValueUpdates)); //TODO: Should we do a debug assert or whatever for testing if lengths match or field update isn't empty? FieldValueUpdateMask = fieldValueUpdateMask ?? throw new ArgumentNullException(nameof(fieldValueUpdateMask)); _FieldValueUpdates = fieldValueUpdates; }
/*========================================================================= ** Allocates a new BitArray with the same length and bit values as bits. ** ** Exceptions: ArgumentException if bits == null. ** =========================================================================*/ public WireReadyBitArray(WireReadyBitArray bits) { if (bits == null) { throw new ArgumentNullException(nameof(bits)); } int arrayLength = bits.InternalArray.Length; //TODO: This could be slower for some lengths: https://stackoverflow.com/a/33865267 InternalArray = new int[arrayLength]; Buffer.BlockCopy(bits.InternalArray, 0, InternalArray, 0, arrayLength * 4); Length = bits.Length; }
/// <summary> /// Overload that supports initializing custom (by the exactly sized) /// <see cref="initialDataSetIndicationArray"/> and entity data <see cref="entityData"/>. /// </summary> /// <param name="initialDataSetIndicationArray">The initial data set array.</param> /// <param name="entityData"></param> public EntityFieldDataCollection(WireReadyBitArray initialDataSetIndicationArray, int[] entityData) { if (initialDataSetIndicationArray == null) { throw new ArgumentNullException(nameof(initialDataSetIndicationArray)); } //TODO: Make this allocation more efficient. Maybe even use pooling. InternalDataFields = entityData ?? throw new ArgumentNullException(nameof(entityData)); if (InternalDataFields.Length != initialDataSetIndicationArray.Length) { throw new ArgumentException($"Failed to initialize entity field data collection due to incorrect Length: {initialDataSetIndicationArray.Length} vs Field Length: {InternalDataFields.Length}"); } DataSetIndicationArray = initialDataSetIndicationArray; }
/// <inheritdoc /> public EntityFieldUpdateCreationContext([NotNull] IEntityDataFieldContainer dataCollection, [NotNull] WireReadyBitArray fieldsToUpdateBitArray) { DataCollection = dataCollection ?? throw new ArgumentNullException(nameof(dataCollection)); FieldsToUpdateBitArray = fieldsToUpdateBitArray ?? throw new ArgumentNullException(nameof(fieldsToUpdateBitArray)); }
/// <inheritdoc /> public ChangeTrackingEntityFieldDataCollectionDecorator(IEntityDataFieldContainer entityDataCollection) { EntityDataCollection = entityDataCollection ?? throw new ArgumentNullException(nameof(entityDataCollection)); ChangeTrackingArray = new WireReadyBitArray(entityDataCollection.DataSetIndicationArray.Length); //just the size of the initial data indiciation bitarray }
public EntityFieldDataCollection() { //TODO: Make this allocation more efficient. Maybe even use pooling. InternalDataFields = new int[ComputeDataFieldCollectionLength()]; DataSetIndicationArray = new WireReadyBitArray(ComputeDataFieldCollectionLength()); }