public bool TestIdentificationGenerator(SDESType one, SDESType two) { var identificationOne = RandomIdentificationGenerator.GetRandomIdentification(); var identificationTwo = RandomIdentificationGenerator.GetRandomIdentification(); return(IsEqual(identificationOne, identificationTwo)); }
private void WritePropertyToBuffer(SDESType type, byte[] data, BufferChunk buffer) { if (data != null) { // Type buffer += (byte)type; // Length buffer += (byte)data.Length; // Data if (data.Length != 0) { buffer += data; } } }
private string GetProperty(SDESType type) { string ret = null; if (data[(int)type] != null) { lock (utf8) { ret = utf8.GetString(data[(int)type]); } } return ret; }
/// <summary> /// --------------------------------------------------------------------------------------- /// Purpose: /// --------------------------------------------------------------------------------------- /// Make sure the data will fit in the 255 bytes (length == 1 byte == byte.MaxValue) /// available to it when converted to UTF8 for transmission across the wire /// /// --------------------------------------------------------------------------------------- /// General structure of an SDES property: /// --------------------------------------------------------------------------------------- /// 0 1 2 3 /// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /// | SDES=N | length | data ... /// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /// </summary> /// <param name="data"></param> private void SetProperty(string data, SDESType type) { byte[] bytes = null; if (data != null) { lock (utf8) { bytes = utf8.GetBytes(data); } // Check to see if it is too long if (bytes.Length > MAX_PROPERTY_LENGTH) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.SDESItemDataBytesExceeded, MAX_PROPERTY_LENGTH, bytes.Length, data)); } } this.data[(int)type] = bytes; }