コード例 #1
0
ファイル: NdefRecord.cs プロジェクト: thecaptncode/iot
        /// <summary>
        /// Create a NDEF Record from a span of bytes
        /// </summary>
        /// <param name="record">A span of bytes containing the NDEF Record</param>
        public NdefRecord(ReadOnlySpan <byte> record)
        {
            Header = new RecordHeader(record);
            var idxRecord = Header.Length;

            if (Header.PayloadLength > 0)
            {
                Payload = new byte[Header.PayloadLength];
                // PayloadLength is a uint32 but can't really be larger than few thousands of bytes, so the cast is safe here
                record.Slice(idxRecord, (int)Header.PayloadLength).CopyTo(Payload);
            }
        }
コード例 #2
0
ファイル: UriRecord.cs プロジェクト: thecaptncode/iot
        /// <summary>
        /// Create a Uri Record from a Uri Type and a Uri
        /// </summary>
        /// <param name="uriType">The Uri type</param>
        /// <param name="uri">A Uri</param>
        public UriRecord(UriType uriType, string uri)
        {
            Header = new RecordHeader()
            {
                TypeNameFormat    = TypeNameFormat.NfcWellKnowType,
                PayloadTypeLength = 1,
                PayloadType       = new byte[1] {
                    0x55
                },
                IdLength = 0,
            };

            _uriType = uriType;
            _uri     = uri;
            SetPayload();
        }
コード例 #3
0
ファイル: NdefRecord.cs プロジェクト: thecaptncode/iot
 /// <summary>
 /// Create an empty NDEF Record, payload will be null
 /// </summary>
 public NdefRecord()
 {
     Header = new RecordHeader();
 }