Instructions

U.are.U SDK - Developer Guide 45
The .NET API
Serialization
The .NET API provides the ability to convert an FMD or FID into a format that can be read serially. Serialization
allows you to easily transmit and store data as byte strings, streams or XML. This allows you to transmit the data or
save it to standard file systems. The XML format can be used within HTML for building browser-based applications.
To return the data to its original format, deserialization is also provided.
Note that serialized FMDs and FIDs include the version number of the .NET wrapper was used for the serialization. If
you attempt to deserialize with an older version of the wrapper, the results may not be correct. So when deserializing,
the .NET wrapper will throw an SDKException if the serialization was done using a later version of the wrapper.
Serialization in the .NET Wrapper occurs using the default
System.Xml.Serialization.XmlSerializer
. The
name of the root element of the generated XML is the same as the object type. Each public member of the object is
represented as an XML element. Raw byte data is encoded as a Base-64 string by
XmlSerializer
.
Deserialization uses the same
XmlSerializer
. The XML that was serialized is fed into
XmlSerializer
where the
elements with values become object members with values of the same name as the element.
IEnumerables in the .NET Wrapper
The .NET wrapper uses the IEnumerable<T> interface (as specified here: http://msdn.microsoft.com/en-us/library/
9eekhta0.aspx). An IEnumerable<T> is a data structure of type T that can be iterated through. An array is one example
of IEnumerable<T>, because it can be iterated, or looped through.
An advantage of IEnumerable is that many different data structures can be used instead of requiring a very specific
type of data structure, such as a 1-dimensional array of type T.
Perhaps the most important advantage of IEnumerables is that whatever is responsible for sending an IEnumerable to a
method may use special semantics such as '
yield return
' to return only a single item at a time. This helps
performance, and also helps programmers simplify their code by allowing .NET wrapper methods to pull only what is
necessary for the operation.
For example,
Enrollment.CreateEnrollmentFmd(IEnumerable<Fmd>)
can iterate through a user’s FMDs until
enough data is captured and then create an enrollment FMD, as opposed to having more data than is necessary. Each
iteration can cause a capture workflow to occur which causes ‘
yield return
’ to return a single item to Enrollment.
NOTE: The
yield return
feature of IEnumerable is available in C# but NOT in VB.NET.
For more information on IEnumerable<T>, consult the Microsoft documentation pages listed below.
Working with Readers
Readers are accessed through the
ReaderCollection
object, which is of type
IEnumerable<Reader>
.
Each attached reader is represented with a
Reader
object. The
Reader
interface allows:
Querying reader description and capabilities,
Acquiring status of the reader,
Capturing fingerprints,
Starting and stopping image stream, and
Resetting and calibrating the reader.
To acquire a reader, call
ReaderCollection.GetReaders()
which returns the attached readers. Iterate through
this list to look at the description object for the desired reader. Once finished with all of the
Reader
objects in the
ReaderCollection
, ensure that you call the
Dispose()
method to un-instantiate the
ReaderCollection
object
and release system resources.
Topic Microsoft Documentation
IEnumerable<T> http://msdn.microsoft.com/en-us/library/9eekhta0.aspx
Yield http://msdn.microsoft.com/en-us/library/9k7k7cf0(v=vs.80).aspx