/// <summary> /// Creates a new unknown value. /// </summary> /// <param name="contents">the binary data from the fudge message</param> /// <param name="type">the unknown type placeholder</param> public UnknownFudgeFieldValue(byte[] contents, UnknownFudgeFieldType type) { if (contents == null) { throw new ArgumentNullException("Contents must be provided"); } if (type == null) { throw new ArgumentNullException("A valid UnknownFudgeFieldType must be specified"); } this.contents = contents; this.type = type; }
/// <summary> /// Returns a type definition for a type ID not defined within this dictionary. This can be used /// to allow the message to be partially processed, preserving the unknown aspects of it. /// </summary> /// <param name="typeId">type ID</param> /// <returns>type definition</returns> public UnknownFudgeFieldType GetUnknownType(int typeId) { if ((unknownTypesById.Length <= typeId) || (unknownTypesById[typeId] == null)) { int newLength = Math.Max(typeId + 1, unknownTypesById.Length); lock (unknownTypesById) { if ((unknownTypesById.Length < newLength) || (unknownTypesById[typeId] == null)) { UnknownFudgeFieldType[] newArray = new UnknownFudgeFieldType[newLength]; unknownTypesById.CopyTo(newArray, 0); newArray[typeId] = new UnknownFudgeFieldType(typeId); unknownTypesById = newArray; } } } Debug.Assert(unknownTypesById[typeId] != null); return unknownTypesById[typeId]; }