NFC / NDEF Library for Proximity APIs  4.1.0
Easily parse and create NDEF records with the Windows Proximity APIs / Near Field Communication NFC.
Public Types | Public Member Functions | Protected Attributes | Properties | List of all members
NdefLibrary.Ndef.NdefRecord Class Reference

An NDEF record contains a payload described by a type, a length, and an optional identifier. More...

Inheritance diagram for NdefLibrary.Ndef.NdefRecord:
NdefLibrary.Ndef.NdefAndroidAppRecord NdefLibrary.Ndef.NdefBtSecureSimplePairingRecord NdefLibrary.Ndef.NdefHandoverAlternativeCarrierRecord NdefLibrary.Ndef.NdefHandoverErrorRecord NdefLibrary.Ndef.NdefHandoverSelectRecord NdefLibrary.Ndef.NdefIcalendarRecordBase NdefLibrary.Ndef.NdefLaunchAppRecord NdefLibrary.Ndef.NdefMimeImageRecordBase NdefLibrary.Ndef.NdefSpActRecord NdefLibrary.Ndef.NdefSpMimeTypeRecord NdefLibrary.Ndef.NdefSpRecord NdefLibrary.Ndef.NdefSpSizeRecord NdefLibrary.Ndef.NdefTextRecord NdefLibrary.Ndef.NdefUriRecord NdefLibrary.Ndef.NdefVcardRecordBase

Public Types

enum  TypeNameFormatType {
  TypeNameFormatType.Empty = 0x00, TypeNameFormatType.NfcRtd = 0x01, TypeNameFormatType.Mime = 0x02, TypeNameFormatType.Uri = 0x03,
  TypeNameFormatType.ExternalRtd = 0x04, TypeNameFormatType.Unknown = 0x05, TypeNameFormatType.Unchanged = 0x06, TypeNameFormatType.Reserved = 0x07
}
 Standardized type name formats, as defined by the NDEF record specification from the Nfc Forum. More...
 

Public Member Functions

 NdefRecord ()
 Create an empty record, not setting any information. More...
 
 NdefRecord (TypeNameFormatType tnf, byte[] type)
 Create a new record with the specified type name format and type. Doesn't set the payload and ID. More...
 
 NdefRecord (NdefRecord other)
 Create a new record, copying the information of the record sent through the parameter. More...
 
Type CheckSpecializedType (bool checkForSubtypes)
 Checks the type name format and type of this record and returns the appropriate specialized class, if one is available and known for this record type. More...
 
virtual bool CheckIfValid ()
 Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue. More...
 

Protected Attributes

byte [] _type
 Byte array storing raw contents of the type. Use Type property to access it whenever possible. More...
 
byte [] _payload
 Byte array storing raw contents of the payload. Use Payload property to access it whenever possible. More...
 

Properties

TypeNameFormatType TypeNameFormat [get, set]
 Indicates the structure of the value of the TYPE field. More...
 
virtual byte [] Type [get, set]
 An identifier describing the type of the payload. More...
 
byte [] Id [get, set]
 An identifier in the form of a URI reference. More...
 
virtual byte [] Payload [get, set]
 The application data carried within an NDEF record. More...
 

Detailed Description

An NDEF record contains a payload described by a type, a length, and an optional identifier.

This class is generic and can hold the data of any kind of record. It follows the specification from the NFC forum for the data format.

Ndef Records should usually be placed within an Ndef Message, which will make sure that for example the message begin / end flags are set correctly.

While the NdefRecord class only offers access to the payload as a byte array, you should rather use specialized sub classes, which offer convenient ways to handle data stored in the payload through easy access methods. Such classes are provided for several standardized types.

Member Enumeration Documentation

◆ TypeNameFormatType

Standardized type name formats, as defined by the NDEF record specification from the Nfc Forum.

Enumerator
Empty 

Empty indicates that no type or payload is associated with this record.

NfcRtd 

The NFC Forum well-known type follows the RTD type name format defined in the NFC Forum RTD specification.

Mime 

The media type indicates that the TYPE field contains a value that follows the media-type BNF construct defined by RFC 2046.

Uri 

Absolute-URI indicates that the TYPE field contains a value that follows the absolute-URI BNF construct defined by RFC 3986.

ExternalRtd 

NFC Forum external type indicates that the TYPE field contains a value that follows the type name format defined in [NFC RTD] for external type names.

Unknown 

Unknown SHOULD be used to indicate that the type of the payload is unknown. This is similar to the "application/octet-stream" media type defined by MIME. When used, the TYPE_LENGTH field MUST be zero and thus the TYPE field is omitted from the NDEF record.

Unchanged 

Unchanged MUST be used in all middle record chunks and the terminating record chunk used in chunked payloads.

Reserved 

Any other type name format; should be treated as unknown.

Constructor & Destructor Documentation

◆ NdefRecord() [1/3]

NdefLibrary.Ndef.NdefRecord.NdefRecord ( )

Create an empty record, not setting any information.

◆ NdefRecord() [2/3]

NdefLibrary.Ndef.NdefRecord.NdefRecord ( TypeNameFormatType  tnf,
byte []  type 
)

Create a new record with the specified type name format and type. Doesn't set the payload and ID.

Parameters
tnfType name format to use, based on the tnf's standardized by the Nfc Forum.
typeType string.

◆ NdefRecord() [3/3]

NdefLibrary.Ndef.NdefRecord.NdefRecord ( NdefRecord  other)

Create a new record, copying the information of the record sent through the parameter.

Parameters
otherRecord to copy.

Member Function Documentation

◆ CheckIfValid()

virtual bool NdefLibrary.Ndef.NdefRecord.CheckIfValid ( )
virtual

Checks if the contents of the record are valid; throws an exception if a problem is found, containing a textual description of the issue.

Exceptions
NdefExceptionThrown if no valid NDEF record can be created based on the record's current contents. The exception message contains further details about the issue.
Returns
True if the record contents are valid, or throws an exception if an issue is found.

Reimplemented in NdefLibrary.Ndef.NdefLaunchAppRecord, NdefLibrary.Ndef.NdefHandoverAlternativeCarrierRecord, NdefLibrary.Ndef.NdefSpRecord, NdefLibrary.Ndef.NdefGeoRecord, NdefLibrary.Ndef.NdefMailtoRecord, NdefLibrary.Ndef.NdefSmsRecord, NdefLibrary.Ndef.NdefTelRecord, and NdefLibrary.Ndef.NdefSocialRecord.

◆ CheckSpecializedType()

Type NdefLibrary.Ndef.NdefRecord.CheckSpecializedType ( bool  checkForSubtypes)

Checks the type name format and type of this record and returns the appropriate specialized class, if one is available and known for this record type.

Parameters
checkForSubtypesIf set to true, also checks for subtypes of the URL / SmartPoster record where the library offers a convenient handling class - e.g. for SMS or Mailto records, which are actually URL schemes.
Returns
Type name of the specialized class that can understand and manipulate the payload through convenience methods.

Member Data Documentation

◆ _payload

byte [] NdefLibrary.Ndef.NdefRecord._payload
protected

Byte array storing raw contents of the payload. Use Payload property to access it whenever possible.

Direct byte array access provided as virtual property can't be accessed from constructor.

◆ _type

byte [] NdefLibrary.Ndef.NdefRecord._type
protected

Byte array storing raw contents of the type. Use Type property to access it whenever possible.

Direct byte array access provided as virtual property can't be accessed from constructor.

Property Documentation

◆ Id

byte [] NdefLibrary.Ndef.NdefRecord.Id
getset

An identifier in the form of a URI reference.

◆ Payload

virtual byte [] NdefLibrary.Ndef.NdefRecord.Payload
getset

The application data carried within an NDEF record.

◆ Type

virtual byte [] NdefLibrary.Ndef.NdefRecord.Type
getset

An identifier describing the type of the payload.

◆ TypeNameFormat

TypeNameFormatType NdefLibrary.Ndef.NdefRecord.TypeNameFormat
getset

Indicates the structure of the value of the TYPE field.


The documentation for this class was generated from the following file: