add Testmessag
This commit is contained in:
272
src/ndefpclib/StyleCop.Cache
Normal file
272
src/ndefpclib/StyleCop.Cache
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
<stylecopresultscache>
|
||||||
|
<version>12</version>
|
||||||
|
<sourcecode name="TextType.cs" parser="StyleCop.CSharp.CsParser">
|
||||||
|
<timestamps>
|
||||||
|
<styleCop>2013.09.19 14:09:50.000</styleCop>
|
||||||
|
<settingsFile>2012.09.27 21:03:32.000</settingsFile>
|
||||||
|
<sourceFile>2013.10.23 10:54:09.249</sourceFile>
|
||||||
|
<parser>2013.09.19 14:09:50.000</parser>
|
||||||
|
<StyleCop.CSharp.DocumentationRules>2013.09.19 14:09:50.000</StyleCop.CSharp.DocumentationRules>
|
||||||
|
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.LayoutRules>2013.09.19 14:09:50.000</StyleCop.CSharp.LayoutRules>
|
||||||
|
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.MaintainabilityRules>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.NamingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.NamingRules>
|
||||||
|
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.OrderingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.OrderingRules>
|
||||||
|
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.ReadabilityRules>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.SpacingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.SpacingRules>
|
||||||
|
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||||
|
</timestamps>
|
||||||
|
<violations>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="FileMustHaveHeader" ruleCheckId="SA1633">
|
||||||
|
<context>The file has no header, the header Xml is invalid, or the header is not located at the top of the file.</context>
|
||||||
|
<line>1</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>1</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>2</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives" ruleCheckId="SA1208">
|
||||||
|
<context>System using directives must be placed before all other using directives.</context>
|
||||||
|
<line>2</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>3</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>4</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>5</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="UsingDirectivesMustBePlacedWithinNamespace" ruleCheckId="SA1200">
|
||||||
|
<context>All using directives must be placed inside of the namespace.</context>
|
||||||
|
<line>6</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: ndefpclib.</context>
|
||||||
|
<line>8</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: type.</context>
|
||||||
|
<line>8</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||||
|
<context>The class must have a documentation header.</context>
|
||||||
|
<line>10</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||||
|
<context>The constructor must have a documentation header.</context>
|
||||||
|
<line>12</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementsMustBeDocumented" ruleCheckId="SA1600">
|
||||||
|
<context>The method must have a documentation header.</context>
|
||||||
|
<line>19</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.LayoutRules" rule="ClosingCurlyBracketMustBeFollowedByBlankLine" ruleCheckId="SA1513">
|
||||||
|
<context>Statements or elements wrapped in curly brackets must be followed by a blank line.</context>
|
||||||
|
<line>24</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.ReadabilityRules" rule="CodeMustNotContainEmptyStatements" ruleCheckId="SA1106">
|
||||||
|
<context>The code contains an extra semicolon.</context>
|
||||||
|
<line>34</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.SpacingRules" rule="SemicolonsMustBeSpacedCorrectly" ruleCheckId="SA1002">
|
||||||
|
<context>Invalid spacing around the semicolon.</context>
|
||||||
|
<line>34</line>
|
||||||
|
<index>1009</index>
|
||||||
|
<endIndex>1009</endIndex>
|
||||||
|
<startLine>34</startLine>
|
||||||
|
<startColumn>50</startColumn>
|
||||||
|
<endLine>34</endLine>
|
||||||
|
<endColumn>50</endColumn>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
</violations>
|
||||||
|
</sourcecode>
|
||||||
|
<sourcecode name="TextMessages.cs" parser="StyleCop.CSharp.CsParser">
|
||||||
|
<timestamps>
|
||||||
|
<styleCop>2013.09.19 14:09:50.000</styleCop>
|
||||||
|
<settingsFile>2012.09.27 21:03:32.000</settingsFile>
|
||||||
|
<sourceFile>2013.10.23 15:18:02.510</sourceFile>
|
||||||
|
<parser>2013.09.19 14:09:50.000</parser>
|
||||||
|
<StyleCop.CSharp.DocumentationRules>2013.09.19 14:09:50.000</StyleCop.CSharp.DocumentationRules>
|
||||||
|
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.LayoutRules>2013.09.19 14:09:50.000</StyleCop.CSharp.LayoutRules>
|
||||||
|
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.MaintainabilityRules>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.NamingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.NamingRules>
|
||||||
|
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.OrderingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.OrderingRules>
|
||||||
|
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.ReadabilityRules>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.SpacingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.SpacingRules>
|
||||||
|
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||||
|
</timestamps>
|
||||||
|
<violations>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="FileHeaderMustShowCopyright" ruleCheckId="SA1634">
|
||||||
|
<context>The file header must contain a copyright tag.</context>
|
||||||
|
<line>1</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.SpacingRules" rule="TabsMustNotBeUsed" ruleCheckId="SA1027">
|
||||||
|
<context>Tabs are not allowed. Use spaces instead.</context>
|
||||||
|
<line>3</line>
|
||||||
|
<index>42</index>
|
||||||
|
<endIndex>54</endIndex>
|
||||||
|
<startLine>3</startLine>
|
||||||
|
<startColumn>1</startColumn>
|
||||||
|
<endLine>3</endLine>
|
||||||
|
<endColumn>13</endColumn>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: ndefpclib.</context>
|
||||||
|
<line>4</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: message.</context>
|
||||||
|
<line>4</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>12</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>19</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.SpacingRules" rule="CommasMustBeSpacedCorrectly" ruleCheckId="SA1001">
|
||||||
|
<context>Invalid spacing around the comma.</context>
|
||||||
|
<line>20</line>
|
||||||
|
<index>809</index>
|
||||||
|
<endIndex>809</endIndex>
|
||||||
|
<startLine>20</startLine>
|
||||||
|
<startColumn>50</startColumn>
|
||||||
|
<endLine>20</endLine>
|
||||||
|
<endColumn>50</endColumn>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
</violations>
|
||||||
|
</sourcecode>
|
||||||
|
<project key="1236787186">
|
||||||
|
<configuration>DEBUG;TRACE</configuration>
|
||||||
|
</project>
|
||||||
|
<sourcecode name="NDEFMessage.cs" parser="StyleCop.CSharp.CsParser">
|
||||||
|
<timestamps>
|
||||||
|
<styleCop>2013.09.19 14:09:50.000</styleCop>
|
||||||
|
<settingsFile>2012.09.27 21:03:32.000</settingsFile>
|
||||||
|
<sourceFile>2013.10.23 15:21:08.323</sourceFile>
|
||||||
|
<parser>2013.09.19 14:09:50.000</parser>
|
||||||
|
<StyleCop.CSharp.DocumentationRules>2013.09.19 14:09:50.000</StyleCop.CSharp.DocumentationRules>
|
||||||
|
<StyleCop.CSharp.DocumentationRules.FilesHashCode>-1945363787</StyleCop.CSharp.DocumentationRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.LayoutRules>2013.09.19 14:09:50.000</StyleCop.CSharp.LayoutRules>
|
||||||
|
<StyleCop.CSharp.LayoutRules.FilesHashCode>0</StyleCop.CSharp.LayoutRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.MaintainabilityRules>
|
||||||
|
<StyleCop.CSharp.MaintainabilityRules.FilesHashCode>0</StyleCop.CSharp.MaintainabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.NamingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.NamingRules>
|
||||||
|
<StyleCop.CSharp.NamingRules.FilesHashCode>0</StyleCop.CSharp.NamingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.OrderingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.OrderingRules>
|
||||||
|
<StyleCop.CSharp.OrderingRules.FilesHashCode>0</StyleCop.CSharp.OrderingRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules>2013.09.19 14:09:50.000</StyleCop.CSharp.ReadabilityRules>
|
||||||
|
<StyleCop.CSharp.ReadabilityRules.FilesHashCode>0</StyleCop.CSharp.ReadabilityRules.FilesHashCode>
|
||||||
|
<StyleCop.CSharp.SpacingRules>2013.09.19 14:09:50.000</StyleCop.CSharp.SpacingRules>
|
||||||
|
<StyleCop.CSharp.SpacingRules.FilesHashCode>0</StyleCop.CSharp.SpacingRules.FilesHashCode>
|
||||||
|
</timestamps>
|
||||||
|
<violations>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="FileHeaderMustShowCopyright" ruleCheckId="SA1634">
|
||||||
|
<context>The file header must contain a copyright tag.</context>
|
||||||
|
<line>1</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.SpacingRules" rule="TabsMustNotBeUsed" ruleCheckId="SA1027">
|
||||||
|
<context>Tabs are not allowed. Use spaces instead.</context>
|
||||||
|
<line>3</line>
|
||||||
|
<index>37</index>
|
||||||
|
<endIndex>49</endIndex>
|
||||||
|
<startLine>3</startLine>
|
||||||
|
<startColumn>1</startColumn>
|
||||||
|
<endLine>3</endLine>
|
||||||
|
<endColumn>13</endColumn>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: ndefpclib.</context>
|
||||||
|
<line>4</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.NamingRules" rule="ElementMustBeginWithUpperCaseLetter" ruleCheckId="SA1300">
|
||||||
|
<context>namespace names begin with an upper-case letter: message.</context>
|
||||||
|
<line>4</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.OrderingRules" rule="SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives" ruleCheckId="SA1208">
|
||||||
|
<context>System using directives must be placed before all other using directives.</context>
|
||||||
|
<line>8</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the summary tag contains incorrectly spelled words: Ndef</context>
|
||||||
|
<line>13</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>13</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>31</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>65</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>97</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
<violation namespace="StyleCop.CSharp.DocumentationRules" rule="ElementDocumentationMustBeSpelledCorrectly" ruleCheckId="SA1650">
|
||||||
|
<context>The documentation text within the remarks tag contains incorrectly spelled words: Stubbfel</context>
|
||||||
|
<line>112</line>
|
||||||
|
<warning>False</warning>
|
||||||
|
</violation>
|
||||||
|
</violations>
|
||||||
|
</sourcecode>
|
||||||
|
</stylecopresultscache>
|
||||||
@@ -1,39 +1,43 @@
|
|||||||
namespace ndefpclib.message
|
// namespace: ndefpclib.message
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.message
|
||||||
{
|
{
|
||||||
using ndefpclib.records;
|
using ndefpclib.records;
|
||||||
using ndefpclib.type;
|
using ndefpclib.type;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
/// <summary>Ndef message.</summary>
|
/// <summary> Ndef message. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public class NDEFMessage
|
public class NDEFMessage
|
||||||
{
|
{
|
||||||
#region Members
|
#region Members
|
||||||
|
|
||||||
/// <summary>The records.</summary>
|
/// <summary> The records. </summary>
|
||||||
private List<NDEFRecord> records;
|
private List<NDEFRecord> records;
|
||||||
|
|
||||||
|
/// <summary> Type of the message. </summary>
|
||||||
|
private MsgType msgType;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region constructors
|
#region constructors
|
||||||
|
|
||||||
|
/// <summary> Initializes a new instance of the NDEFMessage class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="content"> The content. </param>
|
||||||
|
/// <param name="type"> The type. </param>
|
||||||
public NDEFMessage(string content, MsgType type)
|
public NDEFMessage(string content, MsgType type)
|
||||||
{
|
{
|
||||||
this.records = new List<NDEFRecord>();
|
this.records = new List<NDEFRecord>();
|
||||||
float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad;
|
float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad;
|
||||||
NDEFRecord tmpRecord = null;
|
NDEFRecord tmpRecord = null;
|
||||||
string praefix = type.PayloadPrefix;
|
this.msgType = type;
|
||||||
MsgType.TNFVAL tnf = type.TNFValue;
|
|
||||||
MsgType.TYPEVAL typeVal = type.TypeValue;
|
|
||||||
|
|
||||||
for (int i = 0; recordsCount > 0; i++)
|
for (int i = 0; recordsCount > 0; i++)
|
||||||
{
|
{
|
||||||
tmpRecord = new NDEFShortRecord();
|
tmpRecord = new NDEFShortRecord(type);
|
||||||
tmpRecord.Type = typeVal;
|
|
||||||
tmpRecord.TNF = tnf;
|
|
||||||
tmpRecord.PayloadPraefix = praefix;
|
|
||||||
|
|
||||||
int recordsize = 255;
|
int recordsize = 255;
|
||||||
if (content.Length < (i + 1) * recordsize)
|
if (content.Length < (i + 1) * recordsize)
|
||||||
@@ -55,17 +59,17 @@
|
|||||||
this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET;
|
this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the NDEFMessage class.</summary>
|
/// <summary> Initializes a new instance of the NDEFMessage class. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <param name="array">The array.</param>
|
/// <param name="array"> The array. </param>
|
||||||
public NDEFMessage(byte[] array, Encoding payLoadEncoding)
|
public NDEFMessage(byte[] array)
|
||||||
{
|
{
|
||||||
this.records = new List<NDEFRecord>();
|
this.records = new List<NDEFRecord>();
|
||||||
|
|
||||||
NDEFRecord tmpRecord = null;
|
NDEFRecord tmpRecord = null;
|
||||||
for (int i = 0; i < array.Length; i += tmpRecord.RecordSize)
|
for (int i = 0; i < array.Length; i += tmpRecord.RecordSize)
|
||||||
{
|
{
|
||||||
tmpRecord = new NDEFShortRecord(array, payLoadEncoding, i);
|
tmpRecord = new NDEFShortRecord(array, i);
|
||||||
|
|
||||||
this.records.Add(tmpRecord);
|
this.records.Add(tmpRecord);
|
||||||
}
|
}
|
||||||
@@ -73,11 +77,23 @@
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region property
|
||||||
|
|
||||||
|
/// <summary> Gets or sets the type of the message. </summary>
|
||||||
|
/// <value> The type of the message. </value>
|
||||||
|
protected MsgType MsgType
|
||||||
|
{
|
||||||
|
get { return this.msgType; }
|
||||||
|
set { this.msgType = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>Gets the content.</summary>
|
/// <summary> Gets the content. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <returns>The content.</returns>
|
/// <returns> The content. </returns>
|
||||||
public string GetContent()
|
public string GetContent()
|
||||||
{
|
{
|
||||||
string result = string.Empty;
|
string result = string.Empty;
|
||||||
@@ -90,15 +106,15 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Converts this object to a byte array.</summary>
|
/// <summary> Converts this object to a byte array. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <returns>This object as a byte[].</returns>
|
/// <returns> This object as a byte[]. </returns>
|
||||||
public virtual byte[] ToByteArray(Encoding payLoadEncoding)
|
public virtual byte[] ToByteArray()
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
foreach (NDEFRecord record in this.records)
|
foreach (NDEFRecord record in this.records)
|
||||||
{
|
{
|
||||||
ms.Write(record.ToByteArray(payLoadEncoding), 0, record.RecordSize);
|
ms.Write(record.ToByteArray(), 0, record.RecordSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
|
|||||||
23
src/ndefpclib/message/Text/TextMessageUTF16.cs
Normal file
23
src/ndefpclib/message/Text/TextMessageUTF16.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
// namespace: ndefpclib.message.Text
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.message.Text
|
||||||
|
{
|
||||||
|
using ndefpclib.type.Const;
|
||||||
|
|
||||||
|
/// <summary> A text message UTF 16. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <seealso cref="T:ndefpclib.message.Text.TextMessage"/>
|
||||||
|
public class TextMessageUTF16 : TextMessage
|
||||||
|
{
|
||||||
|
/// <summary> Initializes a new instance of the TextMessageUTF16 class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="content"> The content. </param>
|
||||||
|
/// <param name="lang"> The language. </param>
|
||||||
|
public TextMessageUTF16(string content, string lang)
|
||||||
|
: base(content, TextEncoding.UTF16, lang)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/ndefpclib/message/Text/TextMessageUTF8.cs
Normal file
22
src/ndefpclib/message/Text/TextMessageUTF8.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// namespace: ndefpclib.message.Text
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.message.Text
|
||||||
|
{
|
||||||
|
using ndefpclib.type.Const;
|
||||||
|
|
||||||
|
/// <summary> A text message UTF 8. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <seealso cref="T:ndefpclib.message.Text.TextMessage"/>
|
||||||
|
public class TextMessageUTF8 : TextMessage
|
||||||
|
{
|
||||||
|
/// <summary> Initializes a new instance of the TextMessageUTF8 class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="content"> The content. </param>
|
||||||
|
/// <param name="lang"> The language. </param>
|
||||||
|
public TextMessageUTF8(string content, string lang)
|
||||||
|
: base(content, TextEncoding.UTF8, lang)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/ndefpclib/message/Text/TextMessages.cs
Normal file
23
src/ndefpclib/message/Text/TextMessages.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// namespace: ndefpclib.message.Text
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.message.Text
|
||||||
|
{
|
||||||
|
using ndefpclib.type;
|
||||||
|
|
||||||
|
/// <summary> A text message. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <seealso cref="T:ndefpclib.message.NDEFMessage"/>
|
||||||
|
public class TextMessage : NDEFMessage
|
||||||
|
{
|
||||||
|
/// <summary> Initializes a new instance of the TextMessage class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="content"> The content. </param>
|
||||||
|
/// <param name="encoding"> The encoding. </param>
|
||||||
|
/// <param name="lang"> The language. </param>
|
||||||
|
public TextMessage(string content, string encoding, string lang)
|
||||||
|
: base(content, new TextType(encoding,lang))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,6 +38,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="message\NDEFMessage.cs" />
|
<Compile Include="message\NDEFMessage.cs" />
|
||||||
|
<Compile Include="message\Text\TextMessageUTF16.cs" />
|
||||||
|
<Compile Include="message\Text\TextMessages.cs" />
|
||||||
|
<Compile Include="message\Text\TextMessageUTF8.cs" />
|
||||||
<Compile Include="record\NDEFRecord.cs" />
|
<Compile Include="record\NDEFRecord.cs" />
|
||||||
<Compile Include="record\NDEFShortRecord.cs" />
|
<Compile Include="record\NDEFShortRecord.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@@ -46,6 +49,7 @@
|
|||||||
<Compile Include="type\Const\TextEncoding.cs" />
|
<Compile Include="type\Const\TextEncoding.cs" />
|
||||||
<Compile Include="type\TextType.cs" />
|
<Compile Include="type\TextType.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
@@ -1,46 +1,64 @@
|
|||||||
namespace ndefpclib.records
|
// namespace: ndefpclib.records
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.records
|
||||||
{
|
{
|
||||||
using ndefpclib.message;
|
|
||||||
using ndefpclib.type;
|
using ndefpclib.type;
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
/// <summary>Ndef record of a NDEFMessage.</summary>
|
/// <summary> Ndef record of a NDEFMessage. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public abstract class NDEFRecord
|
public abstract class NDEFRecord
|
||||||
{
|
{
|
||||||
#region Members
|
#region Members
|
||||||
|
|
||||||
/// <summary>The maximum record pay load.</summary>
|
/// <summary> The maximum record pay load. </summary>
|
||||||
public const int MaxRecordPayLoad = 255;
|
public const int MaxRecordPayLoad = 255;
|
||||||
|
|
||||||
/// <summary>Size of the type.</summary>
|
/// <summary> Size of the type. </summary>
|
||||||
protected const byte TypeSize = 0x01;
|
protected const byte TypeSize = 0x01;
|
||||||
|
|
||||||
|
/// <summary> Type of the message. </summary>
|
||||||
|
private MsgType msgType;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
/// <summary>Initializes a new instance of the NDEFRecord class.</summary>
|
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <summary> Initializes a new instance of the NDEFRecord class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public NDEFRecord()
|
public NDEFRecord()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the NDEFRecord class.</summary>
|
/// <summary> Initializes a new instance of the NDEFRecord class. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <param name="array">The array.</param>
|
/// <param name="array"> The array. </param>
|
||||||
/// <param name="index">(Optional) zero-based index of the.</param>
|
/// <param name="headerSize"> The size of the header. </param>
|
||||||
public NDEFRecord(byte[] array, int index = 0)
|
/// <param name="index"> (Optional) zero-based index of the. </param>
|
||||||
|
public NDEFRecord(byte[] array, int headerSize,int index = 0)
|
||||||
{
|
{
|
||||||
|
this.msgType = MsgType.GetType(array, index);
|
||||||
|
this.HeaderSize = headerSize;
|
||||||
this.FormatFlags = array[index];
|
this.FormatFlags = array[index];
|
||||||
|
int payLoadSize = array[index + 2] - this.PayloadPraefix.Length;
|
||||||
|
this.Payload = msgType.Encoder.GetString(array, index + this.HeaderSize + this.PayloadPraefix.Length, payLoadSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Initializes a new instance of the NDEFRecord class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="type"> The type. </param>
|
||||||
|
public NDEFRecord(MsgType type)
|
||||||
|
{
|
||||||
|
this.msgType = type;
|
||||||
|
this.PayloadPraefix = type.PayloadPrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region enum
|
#region enum
|
||||||
|
|
||||||
/// <summary>Values that represent NDEFFlags.</summary>
|
/// <summary> Values that represent NDEFFlags. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public enum NDEFFlags
|
public enum NDEFFlags
|
||||||
{
|
{
|
||||||
/// <summary>An Enum constant representing the UNSET option.</summary>
|
/// <summary>An Enum constant representing the UNSET option.</summary>
|
||||||
@@ -68,43 +86,44 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
/// <summary>Gets or sets the MBFlag.</summary>
|
|
||||||
/// <value>The MBFlag.</value>
|
/// <summary> Gets or sets the MBFlag. </summary>
|
||||||
|
/// <value> The MBFlag. </value>
|
||||||
public NDEFFlags MB { get; set; }
|
public NDEFFlags MB { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets MEFlag.</summary>
|
/// <summary> Gets or sets MEFlag. </summary>
|
||||||
/// <value>The MEFlag .</value>
|
/// <value> The MEFlag . </value>
|
||||||
public NDEFFlags ME { get; set; }
|
public NDEFFlags ME { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the CFFlag.</summary>
|
/// <summary> Gets or sets the CFFlag. </summary>
|
||||||
/// <value>The CFFlag.</value>
|
/// <value> The CFFlag. </value>
|
||||||
public NDEFFlags CF { get; set; }
|
public NDEFFlags CF { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the SRFlag.</summary>
|
/// <summary> Gets or sets the SRFlag. </summary>
|
||||||
/// <value>The SRFlag.</value>
|
/// <value> The SRFlag. </value>
|
||||||
public NDEFFlags SR { get; set; }
|
public NDEFFlags SR { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the ILFlag.</summary>
|
/// <summary> Gets or sets the ILFlag. </summary>
|
||||||
/// <value>The ILFlag.</value>
|
/// <value> The ILFlag. </value>
|
||||||
public NDEFFlags IL { get; set; }
|
public NDEFFlags IL { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets or sets the TNFField.</summary>
|
/// <summary> Gets or sets the TNFField. </summary>
|
||||||
/// <value>The TNFField.</value>
|
/// <value> The TNFField. </value>
|
||||||
public MsgType.TNFVAL TNF { get; set; }
|
public MsgType.TNFVAL TNF { get { return this.MsgType.TNFValue; } set { this.MsgType.TNFValue = value; } }
|
||||||
|
|
||||||
/// <summary>Gets or sets the type.</summary>
|
/// <summary> Gets or sets the type. </summary>
|
||||||
/// <value>The type.</value>
|
/// <value> The type. </value>
|
||||||
public MsgType.TYPEVAL Type { get; set; }
|
public MsgType.TYPEVAL Type { get { return this.MsgType.TypeValue; } set { this.MsgType.TypeValue = value; } }
|
||||||
|
|
||||||
/// <summary>Gets or sets the format flags.</summary>
|
/// <summary> Gets the format flags. </summary>
|
||||||
/// <value>The format flags.</value>
|
/// <value> The format flags. </value>
|
||||||
public byte FormatFlags
|
public byte FormatFlags
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL));
|
return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
this.TNF = (MsgType.TNFVAL)(value & (byte)NDEFFlags.TNFSET);
|
this.TNF = (MsgType.TNFVAL)(value & (byte)NDEFFlags.TNFSET);
|
||||||
@@ -116,12 +135,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets or sets the payload.</summary>
|
/// <summary> Gets or sets the payload. </summary>
|
||||||
/// <value>The payload.</value>
|
/// <value> The payload. </value>
|
||||||
public string Payload { get; set; }
|
public string Payload { get; set; }
|
||||||
|
|
||||||
/// <summary>Gets the size of the record.</summary>
|
/// <summary> Gets the size of the record. </summary>
|
||||||
/// <value>The size of the record.</value>
|
/// <value> The size of the record. </value>
|
||||||
public int RecordSize
|
public int RecordSize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -130,22 +149,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets or sets the payload praefix.</summary>
|
/// <summary> Gets or sets the payload praefix. </summary>
|
||||||
/// <value>The payload praefix.</value>
|
/// <value> The payload praefix. </value>
|
||||||
public string PayloadPraefix { get; set; }
|
public string PayloadPraefix { get { return this.MsgType.PayloadPrefix; } set { this.MsgType.PayloadPrefix = value; } }
|
||||||
|
|
||||||
/// <summary>Gets or sets the size of the header.</summary>
|
/// <summary> Gets or sets the size of the header. </summary>
|
||||||
/// <value>The size of the header.</value>
|
/// <value> The size of the header. </value>
|
||||||
protected int HeaderSize { get; set; }
|
protected int HeaderSize { get; set; }
|
||||||
|
|
||||||
|
/// <summary> Gets the type of the message. </summary>
|
||||||
|
/// <value> The type of the message. </value>
|
||||||
|
public MsgType MsgType
|
||||||
|
{
|
||||||
|
get { return msgType; }
|
||||||
|
protected set { msgType = value; }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
/// <summary>Converts the record to a byte array.</summary>
|
/// <summary> Converts the record to a byte array. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <returns>This object as a byte[].</returns>
|
/// <returns> This object as a byte[]. </returns>
|
||||||
public abstract byte[] ToByteArray(Encoding payLoadEncoding);
|
public abstract byte[] ToByteArray();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
namespace ndefpclib.records
|
// namespace: ndefpclib.records
|
||||||
|
//
|
||||||
|
// summary: .
|
||||||
|
namespace ndefpclib.records
|
||||||
{
|
{
|
||||||
using ndefpclib.message;
|
using ndefpclib.message;
|
||||||
using ndefpclib.type;
|
using ndefpclib.type;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
/// <summary>Ndef short record.</summary>
|
/// <summary> Ndef short record. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
|
/// <seealso cref="T:ndefpclib.records.NDEFRecord"/>
|
||||||
public class NDEFShortRecord : NDEFRecord
|
public class NDEFShortRecord : NDEFRecord
|
||||||
{
|
{
|
||||||
/// <summary>Initializes a new instance of the NDEFShortRecord class.</summary>
|
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public NDEFShortRecord()
|
public NDEFShortRecord()
|
||||||
{
|
{
|
||||||
this.HeaderSize = 4;
|
this.HeaderSize = 4;
|
||||||
@@ -18,26 +22,35 @@
|
|||||||
this.CF = NDEFFlags.UNSET;
|
this.CF = NDEFFlags.UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the NDEFShortRecord class.</summary>
|
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <param name="array">The array.</param>
|
/// <param name="array"> The array. </param>
|
||||||
/// <param name="index">(Optional) zero-based index of the.</param>
|
/// <param name="index"> (Optional) zero-based index of the. </param>
|
||||||
public NDEFShortRecord(byte[] array, Encoding payLoadEncoding, int index = 0)
|
public NDEFShortRecord(byte[] array, int index = 0)
|
||||||
: base(array)
|
: base(array, 4)
|
||||||
{
|
{
|
||||||
this.HeaderSize = 4;
|
this.SR = NDEFFlags.SRSET;
|
||||||
this.Type = (MsgType.TYPEVAL)array[index + 3];
|
this.IL = NDEFFlags.UNSET;
|
||||||
this.PayloadPraefix = MsgType.GetPraefix(this.Type);
|
this.CF = NDEFFlags.UNSET;
|
||||||
int payLoadSize = array[index + 2] - this.PayloadPraefix.Length;
|
|
||||||
this.Payload = payLoadEncoding.GetString(array, index + this.HeaderSize + this.PayloadPraefix.Length, payLoadSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Converts this NDEFShortRecord to a byte array.</summary>
|
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
/// <returns>This object as a byte[].</returns>
|
/// <param name="type"> The type. </param>
|
||||||
public override byte[] ToByteArray(Encoding payLoadEncoding)
|
public NDEFShortRecord(MsgType type) : base(type)
|
||||||
{
|
{
|
||||||
byte[] payloadAr = payLoadEncoding.GetBytes(this.PayloadPraefix + this.Payload);
|
this.HeaderSize = 4;
|
||||||
|
this.SR = NDEFFlags.SRSET;
|
||||||
|
this.IL = NDEFFlags.UNSET;
|
||||||
|
this.CF = NDEFFlags.UNSET;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Converts this NDEFShortRecord to a byte array. </summary>
|
||||||
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
|
/// <seealso cref="M:ndefpclib.records.NDEFRecord.ToByteArray()"/>
|
||||||
|
public override byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
byte[] payloadAr = this.MsgType.Encoder.GetBytes(this.PayloadPraefix + this.Payload);
|
||||||
byte[] array = new byte[payloadAr.Length + this.HeaderSize];
|
byte[] array = new byte[payloadAr.Length + this.HeaderSize];
|
||||||
|
|
||||||
array[0] = this.FormatFlags;
|
array[0] = this.FormatFlags;
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
// namespace: ndefpclib.type.Const
|
||||||
using System.Linq;
|
//
|
||||||
using System.Text;
|
// summary: .
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ndefpclib.type.Const
|
namespace ndefpclib.type.Const
|
||||||
{
|
{
|
||||||
|
/// <summary> A language. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
public class Language
|
public class Language
|
||||||
{
|
{
|
||||||
|
/// <summary> The de. </summary>
|
||||||
public const string DE ="de";
|
public const string DE ="de";
|
||||||
|
|
||||||
|
/// <summary> The en. </summary>
|
||||||
public const string EN = "en";
|
public const string EN = "en";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,36 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
// namespace: ndefpclib.type.Const
|
||||||
using System.Linq;
|
//
|
||||||
using System.Text;
|
// summary: .
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ndefpclib.type.Const
|
namespace ndefpclib.type.Const
|
||||||
{
|
{
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/// <summary> A text encoding. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
public class TextEncoding
|
public class TextEncoding
|
||||||
{
|
{
|
||||||
|
/// <summary> The UTF 8. </summary>
|
||||||
public const string UTF8 = "\x02";
|
public const string UTF8 = "\x02";
|
||||||
|
|
||||||
//public const string UTF16 = "\x82";
|
/// <summary> The UTF 16. </summary>
|
||||||
|
public const string UTF16 = "\x82";
|
||||||
|
|
||||||
|
/// <summary> Gets an encoding. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="input"> The input. </param>
|
||||||
|
/// <returns> The encoding. </returns>
|
||||||
|
public static Encoding GetEncoding(string input)
|
||||||
|
{
|
||||||
|
switch (input)
|
||||||
|
{
|
||||||
|
case UTF8:
|
||||||
|
return Encoding.UTF8;
|
||||||
|
case UTF16:
|
||||||
|
return Encoding.Unicode;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,51 @@
|
|||||||
using ndefpclib.type.Const;
|
|
||||||
using System;
|
// namespace: ndefpclib.type
|
||||||
using System.Collections.Generic;
|
//
|
||||||
using System.Linq;
|
// summary: .
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ndefpclib.type
|
namespace ndefpclib.type
|
||||||
{
|
{
|
||||||
|
using ndefpclib.type.Const;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/// <summary> A text type. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <seealso cref="T:ndefpclib.type.MsgType"/>
|
||||||
public class TextType : MsgType
|
public class TextType : MsgType
|
||||||
{
|
{
|
||||||
|
/// <summary> Initializes a new instance of the TextType class. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="encoding"> (Optional) the encoding. </param>
|
||||||
|
/// <param name="lang"> (Optional) the language. </param>
|
||||||
public TextType(string encoding = TextEncoding.UTF8, string lang = Language.DE)
|
public TextType(string encoding = TextEncoding.UTF8, string lang = Language.DE)
|
||||||
{
|
{
|
||||||
this.TNFValue = TNFVAL.WKT;
|
this.TNFValue = TNFVAL.WKT;
|
||||||
this.TypeValue = TYPEVAL.TEXT;
|
this.TypeValue = TYPEVAL.TEXT;
|
||||||
|
this.Encoder = TextEncoding.GetEncoding(encoding);
|
||||||
this.PayloadPrefix = encoding + lang;
|
this.PayloadPrefix = encoding + lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets text type. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="array"> The array. </param>
|
||||||
|
/// <param name="index"> Zero-based index of the. </param>
|
||||||
|
/// <returns> The text type. </returns>
|
||||||
|
public static TextType GetTextType(byte[] array, int index)
|
||||||
|
{
|
||||||
|
if (index + 6 >= array.Length)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string encoding = string.Format("{0}", (char)array[index + 4]);
|
||||||
|
Encoding encoder = TextEncoding.GetEncoding(encoding);
|
||||||
|
|
||||||
|
if (encoder == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string lang = encoder.GetString(array, 5, 2);
|
||||||
|
return new TextType(encoding, lang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
// namespace: ndefpclib.type
|
||||||
using System.Linq;
|
//
|
||||||
using System.Text;
|
// summary: .
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ndefpclib.type
|
namespace ndefpclib.type
|
||||||
{
|
{
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/// <summary> A message type. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
public abstract class MsgType
|
public abstract class MsgType
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
#region enum
|
#region enum
|
||||||
|
|
||||||
/// <summary>Values that represent TYPEVAL.</summary>
|
/// <summary> Values that represent TYPEVAL. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public enum TYPEVAL
|
public enum TYPEVAL
|
||||||
{
|
{
|
||||||
/// <summary>An enum constant representing the empty option.</summary>
|
/// <summary>An enum constant representing the empty option.</summary>
|
||||||
@@ -26,8 +27,8 @@ namespace ndefpclib.type
|
|||||||
TEXT = 0x54
|
TEXT = 0x54
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Values that represent TNFVAL.</summary>
|
/// <summary> Values that represent TNFVAL. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
public enum TNFVAL
|
public enum TNFVAL
|
||||||
{
|
{
|
||||||
/// <summary>An enum constant representing the empty option.</summary>
|
/// <summary>An enum constant representing the empty option.</summary>
|
||||||
@@ -57,18 +58,32 @@ namespace ndefpclib.type
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region property
|
#region property
|
||||||
public TYPEVAL TypeValue { get; protected set; }
|
|
||||||
public string PayloadPrefix { get; protected set; }
|
/// <summary> Gets or sets the type value. </summary>
|
||||||
public TNFVAL TNFValue { get; protected set; }
|
/// <value> The type value. </value>
|
||||||
|
public TYPEVAL TypeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary> Gets or sets the payload prefix. </summary>
|
||||||
|
/// <value> The payload prefix. </value>
|
||||||
|
public string PayloadPrefix { get; set; }
|
||||||
|
|
||||||
|
/// <summary> Gets or sets the tnf value. </summary>
|
||||||
|
/// <value> The tnf value. </value>
|
||||||
|
public TNFVAL TNFValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary> Gets or sets the encoder. </summary>
|
||||||
|
/// <value> The encoder. </value>
|
||||||
|
public Encoding Encoder { get; set; }
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region methods
|
#region methods
|
||||||
|
|
||||||
/// <summary>Gets a praefix.</summary>
|
/// <summary> Gets a praefix. </summary>
|
||||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||||
/// <param name="type">The type.</param>
|
/// <param name="type"> The type. </param>
|
||||||
/// <returns>The praefix.</returns>
|
/// <returns> The praefix. </returns>
|
||||||
public static string GetPraefix(MsgType.TYPEVAL type)
|
public static string GetPraefix(MsgType.TYPEVAL type)
|
||||||
{
|
{
|
||||||
string praefix = string.Empty;
|
string praefix = string.Empty;
|
||||||
@@ -87,6 +102,28 @@ namespace ndefpclib.type
|
|||||||
|
|
||||||
return praefix;
|
return praefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets a type. </summary>
|
||||||
|
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||||
|
/// <param name="array"> The array. </param>
|
||||||
|
/// <param name="index"> Zero-based index of the. </param>
|
||||||
|
/// <returns> The type. </returns>
|
||||||
|
public static MsgType GetType(byte[] array, int index)
|
||||||
|
{
|
||||||
|
MsgType result = null;
|
||||||
|
MsgType.TYPEVAL typeEval = (MsgType.TYPEVAL)array[index + 3];
|
||||||
|
switch (typeEval)
|
||||||
|
{
|
||||||
|
case MsgType.TYPEVAL.TEXT:
|
||||||
|
result = TextType.GetTextType(array, index);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user