Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef8715aea4 | ||
|
|
6244a9f0cb | ||
|
|
7e6a25af8e | ||
|
|
1d85089e85 | ||
|
|
0cdf74b417 | ||
|
|
b21f26cfa6 | ||
|
|
2d2051e152 | ||
|
|
430f9d8e41 | ||
|
|
e14537fd57 | ||
|
|
77d0156a94 | ||
|
|
62671c0593 | ||
|
|
1946124e9e |
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
src/ndefpclib/obj/
|
||||
src/ndefpclib/bin/Debug/ndefpclib.dll
|
||||
src/ndefpclib/bin/Debug/ndefpclib.pdb
|
||||
src/ndefpclib/bin/Release/ndefpclib.dll
|
||||
src/ndefpclib/bin/Release/ndefpclib.pdb
|
||||
@@ -1,154 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NDEFMessage.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>21.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.NDEF
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>Ndef message.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public class NDEFMessage
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>The records.</summary>
|
||||
private List<NDEFRecord> records;
|
||||
|
||||
#endregion
|
||||
|
||||
#region constructors
|
||||
|
||||
/// <summary>Initializes a new instance of the NDEFMessage class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <param name="content">The content.</param>
|
||||
/// <param name="type"> The type.</param>
|
||||
/// <param name="tnf"> (Optional) the tnf.</param>
|
||||
public NDEFMessage(string content, TYPEVAL type, NDEFRecord.TNFVAL tnf = NDEFRecord.TNFVAL.WKT)
|
||||
{
|
||||
this.records = new List<NDEFRecord>();
|
||||
float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad;
|
||||
NDEFRecord tmpRecord = null;
|
||||
string praefix = NDEFMessage.GetPraefix(type);
|
||||
|
||||
for (int i = 0; recordsCount > 0; i++)
|
||||
{
|
||||
tmpRecord = new NDEFShortRecord();
|
||||
tmpRecord.Type = type;
|
||||
tmpRecord.TNF = tnf;
|
||||
tmpRecord.PayloadPraefix = praefix;
|
||||
int recordsize = 255;
|
||||
if (content.Length < (i + 1) * recordsize)
|
||||
{
|
||||
recordsize = content.Length - (i * recordsize);
|
||||
}
|
||||
|
||||
tmpRecord.Payload = content.Substring(i * 255, recordsize);
|
||||
if (i == 0)
|
||||
{
|
||||
tmpRecord.MB = NDEFRecord.NDEFFlags.MBSET;
|
||||
}
|
||||
|
||||
this.records.Add(tmpRecord);
|
||||
recordsCount--;
|
||||
}
|
||||
|
||||
this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the NDEFMessage class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <param name="array">The array.</param>
|
||||
public NDEFMessage(byte[] array)
|
||||
{
|
||||
this.records = new List<NDEFRecord>();
|
||||
|
||||
NDEFRecord tmpRecord = null;
|
||||
for (int i = 0; i < array.Length; i += tmpRecord.RecordSize)
|
||||
{
|
||||
tmpRecord = new NDEFShortRecord(array, i);
|
||||
|
||||
this.records.Add(tmpRecord);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region enum
|
||||
|
||||
/// <summary>Values that represent TYPEVAL.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public enum TYPEVAL
|
||||
{
|
||||
/// <summary>An enum constant representing the empty option.</summary>
|
||||
EMPTY = 0x00,
|
||||
|
||||
/// <summary>An enum constant representing the URL option.</summary>
|
||||
URL = 0x55,
|
||||
|
||||
/// <summary>An enum constant representing the text option.</summary>
|
||||
TEXT = 0x54,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
/// <summary>Gets a praefix.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>The praefix.</returns>
|
||||
public static string GetPraefix(TYPEVAL type)
|
||||
{
|
||||
string praefix = string.Empty;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case TYPEVAL.TEXT:
|
||||
praefix = "\x02" + "de";
|
||||
break;
|
||||
case TYPEVAL.URL:
|
||||
praefix = "\x01";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return praefix;
|
||||
}
|
||||
|
||||
/// <summary>Gets the content.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <returns>The content.</returns>
|
||||
public string GetContent()
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
foreach (NDEFRecord record in this.records)
|
||||
{
|
||||
result += record.Payload;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>Converts this object to a byte array.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <returns>This object as a byte[].</returns>
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
foreach (NDEFRecord record in this.records)
|
||||
{
|
||||
ms.Write(record.ToByteArray(), 0, record.RecordSize);
|
||||
}
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NDEFRecord.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>21.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.NDEF
|
||||
{
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
/// <summary>Ndef record of a NDEFMessage.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public abstract class NDEFRecord
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary>The maximum record pay load.</summary>
|
||||
public const int MaxRecordPayLoad = 255;
|
||||
|
||||
/// <summary>Size of the type.</summary>
|
||||
protected const byte TypeSize = 0x01;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>Initializes a new instance of the NDEFRecord class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public NDEFRecord()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the NDEFRecord class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <param name="array">The array.</param>
|
||||
/// <param name="index">(Optional) zero-based index of the.</param>
|
||||
public NDEFRecord(byte[] array, int index = 0)
|
||||
{
|
||||
this.FormatFlags = array[index];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region enum
|
||||
|
||||
/// <summary>Values that represent NDEFFlags.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public enum NDEFFlags
|
||||
{
|
||||
/// <summary>An Enum constant representing the UNSET option.</summary>
|
||||
UNSET = 0x00,
|
||||
|
||||
/// <summary>An Enum constant representing the Message begin option.</summary>
|
||||
MBSET = 0x80,
|
||||
|
||||
/// <summary>An Enum constant representing the Message end option.</summary>
|
||||
MESET = 0x40,
|
||||
|
||||
/// <summary>An Enum constant representing the CHUNK FLAG option.</summary>
|
||||
CFSET = 0x20,
|
||||
|
||||
/// <summary>An Enum constant representing the Short Record set option.</summary>
|
||||
SRSET = 0x10,
|
||||
|
||||
/// <summary>An Enum constant representing the ID length option.</summary>
|
||||
ILSET = 0x08,
|
||||
|
||||
/// <summary>An enum constant representing the tnfset option.</summary>
|
||||
TNFSET = 0x03
|
||||
}
|
||||
|
||||
/// <summary>Values that represent TNFVAL.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public enum TNFVAL
|
||||
{
|
||||
/// <summary>An enum constant representing the empty option.</summary>
|
||||
EMPTY = 0x00,
|
||||
|
||||
/// <summary>An enum constant representing the Well-Know-Type option.</summary>
|
||||
WKT = 0x01,
|
||||
|
||||
/// <summary>An enum constant representing the MediaType option.</summary>
|
||||
MEDIATYPE = 0x02,
|
||||
|
||||
/// <summary>An enum constant representing the URI option.</summary>
|
||||
URI = 0x03,
|
||||
|
||||
/// <summary>An enum constant representing the NFCE option.</summary>
|
||||
NFCE = 0x04,
|
||||
|
||||
/// <summary>An enum constant representing the unknow option.</summary>
|
||||
unknow = 0x05,
|
||||
|
||||
/// <summary>An enum constant representing the unchanged option.</summary>
|
||||
UNCHANGED = 0x06,
|
||||
|
||||
/// <summary>An enum constant representing the reserved option.</summary>
|
||||
RESERVED = 0x07
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
/// <summary>Gets or sets the MBFlag.</summary>
|
||||
/// <value>The MBFlag.</value>
|
||||
public NDEFFlags MB { get; set; }
|
||||
|
||||
/// <summary>Gets or sets MEFlag.</summary>
|
||||
/// <value>The MEFlag .</value>
|
||||
public NDEFFlags ME { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the CFFlag.</summary>
|
||||
/// <value>The CFFlag.</value>
|
||||
public NDEFFlags CF { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the SRFlag.</summary>
|
||||
/// <value>The SRFlag.</value>
|
||||
public NDEFFlags SR { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the ILFlag.</summary>
|
||||
/// <value>The ILFlag.</value>
|
||||
public NDEFFlags IL { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the TNFField.</summary>
|
||||
/// <value>The TNFField.</value>
|
||||
public TNFVAL TNF { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the type.</summary>
|
||||
/// <value>The type.</value>
|
||||
public NDEFMessage.TYPEVAL Type { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the format flags.</summary>
|
||||
/// <value>The format flags.</value>
|
||||
public byte FormatFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL));
|
||||
}
|
||||
|
||||
protected set
|
||||
{
|
||||
this.TNF = (TNFVAL)(value & (byte)NDEFFlags.TNFSET);
|
||||
this.MB = (NDEFFlags)(value & (byte)NDEFFlags.MBSET);
|
||||
this.ME = (NDEFFlags)(value & (byte)NDEFFlags.MESET);
|
||||
this.CF = (NDEFFlags)(value & (byte)NDEFFlags.CFSET);
|
||||
this.SR = (NDEFFlags)(value & (byte)NDEFFlags.SRSET);
|
||||
this.IL = (NDEFFlags)(value & (byte)NDEFFlags.ILSET);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the payload.</summary>
|
||||
/// <value>The payload.</value>
|
||||
public string Payload { get; set; }
|
||||
|
||||
/// <summary>Gets the size of the record.</summary>
|
||||
/// <value>The size of the record.</value>
|
||||
public int RecordSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.HeaderSize + this.Payload.Length + this.PayloadPraefix.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the payload praefix.</summary>
|
||||
/// <value>The payload praefix.</value>
|
||||
public string PayloadPraefix { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the size of the header.</summary>
|
||||
/// <value>The size of the header.</value>
|
||||
protected int HeaderSize { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary>Converts the record to a byte array.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <returns>This object as a byte[].</returns>
|
||||
public abstract byte[] ToByteArray();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
// End of Utility\NDEF\NDEFRecord.cs
|
||||
@@ -1,63 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NDEFShortRecord.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>21.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.NDEF
|
||||
{
|
||||
using System.Text;
|
||||
|
||||
/// <summary>Ndef short record.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public class NDEFShortRecord : NDEFRecord
|
||||
{
|
||||
/// <summary>Initializes a new instance of the NDEFShortRecord class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
public NDEFShortRecord()
|
||||
{
|
||||
this.HeaderSize = 4;
|
||||
this.SR = NDEFFlags.SRSET;
|
||||
this.IL = NDEFFlags.UNSET;
|
||||
this.CF = NDEFFlags.UNSET;
|
||||
}
|
||||
|
||||
/// <summary>Initializes a new instance of the NDEFShortRecord class.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <param name="array">The array.</param>
|
||||
/// <param name="index">(Optional) zero-based index of the.</param>
|
||||
public NDEFShortRecord(byte[] array, int index = 0)
|
||||
: base(array)
|
||||
{
|
||||
this.HeaderSize = 4;
|
||||
this.Type = (NDEFMessage.TYPEVAL)array[index + 3];
|
||||
this.PayloadPraefix = NDEFMessage.GetPraefix(this.Type);
|
||||
int payLoadSize = array[index + 2] - this.PayloadPraefix.Length;
|
||||
this.Payload = Encoding.UTF8.GetString(array, index + this.HeaderSize + this.PayloadPraefix.Length, payLoadSize);
|
||||
}
|
||||
|
||||
/// <summary>Converts this NDEFShortRecord to a byte array.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <returns>This object as a byte[].</returns>
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
byte[] payloadAr = Encoding.UTF8.GetBytes(this.PayloadPraefix + this.Payload);
|
||||
byte[] array = new byte[payloadAr.Length + this.HeaderSize];
|
||||
|
||||
array[0] = this.FormatFlags;
|
||||
array[1] = NDEFRecord.TypeSize;
|
||||
array[2] = (byte)(Payload.Length + this.PayloadPraefix.Length);
|
||||
array[3] = (byte)this.Type;
|
||||
|
||||
int i = this.HeaderSize;
|
||||
foreach (byte b in payloadAr)
|
||||
{
|
||||
array[i] = b;
|
||||
i++;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<phone:PhoneApplicationPage
|
||||
x:Class="CampusAppWP8.Pages.Dev.NFC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
mc:Ignorable="d"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
|
||||
<StackPanel Grid.Row="0" Margin="12,17,0,28">
|
||||
<TextBlock Text="Campusapp" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||
<TextBlock Text="NFC" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
|
||||
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||
<StackPanel>
|
||||
<TextBlock Name="Writecontent" Height="500"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Write" Name="Write" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Write_Click"/>
|
||||
<Button Content="Prev" Name="Prev" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Prev_Click"/>
|
||||
<Button Content="Next" Name="Next" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Next_Click"/>
|
||||
<Button Content="Read" Name="Read" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Read_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -1,127 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NFC.xaml.cs" company="BTU/IIT">
|
||||
// Company copyright tag.
|
||||
// </copyright>
|
||||
// <author>stubbfel</author>
|
||||
// <sience>08.08.2013</sience>
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
namespace CampusAppWP8.Pages.Dev
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Windows;
|
||||
using System.Windows.Navigation;
|
||||
using CampusAppWP8.Model.Campusmap;
|
||||
using CampusAppWP8.Model.GeoDb;
|
||||
using CampusAppWP8.Utility.NDEF;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Windows.Networking.Proximity;
|
||||
|
||||
/// <summary>Nfc page.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
public partial class NFC : PhoneApplicationPage
|
||||
{
|
||||
/// <summary>The device.</summary>
|
||||
private readonly ProximityDevice device = ProximityDevice.GetDefault();
|
||||
|
||||
/// <summary>Zero-based index of the act ndef.</summary>
|
||||
private int actNDEFIndex;
|
||||
|
||||
/// <summary>List of ndefs.</summary>
|
||||
private List<NDEFMessage> ndefList;
|
||||
|
||||
/// <summary>Initializes a new instance of the NFC class.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
public NFC()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.ndefList = new List<NDEFMessage>();
|
||||
MapModel map = new CBMainMapModel();
|
||||
foreach (PlaceModel place in map.Spatial.Places)
|
||||
{
|
||||
this.ndefList.Add(new NDEFMessage(place.ToNfcString(), NDEFMessage.TYPEVAL.TEXT));
|
||||
}
|
||||
|
||||
this.actNDEFIndex = 0;
|
||||
}
|
||||
|
||||
/// <summary>Override the OnNavigatedTo method.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="e">Arguments of navigation.</param>
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
|
||||
}
|
||||
|
||||
/// <summary>Handler, called when the publish.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender"> The sender.</param>
|
||||
/// <param name="messageId">Identifier for the message.</param>
|
||||
private void PublishHandler(ProximityDevice sender, long messageId)
|
||||
{
|
||||
this.device.StopPublishingMessage(messageId);
|
||||
this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show("Writed:" + this.actNDEFIndex)));
|
||||
}
|
||||
|
||||
/// <summary>Handler, called when the ndef.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender"> The sender.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
private void NDEFHandler(ProximityDevice sender, ProximityMessage message)
|
||||
{
|
||||
this.device.StopSubscribingForMessage(message.SubscriptionId);
|
||||
var ndefMessage = message.Data;
|
||||
byte[] testa = ndefMessage.ToArray();
|
||||
|
||||
NDEFMessage ndef = new NDEFMessage(testa);
|
||||
this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
|
||||
}
|
||||
|
||||
/// <summary>Event handler. Called by Read for click events.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e"> Routed event information.</param>
|
||||
private void Read_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.device.SubscribeForMessage("NDEF", this.NDEFHandler);
|
||||
}
|
||||
|
||||
/// <summary>Event handler. Called by Next for click events.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e"> Routed event information.</param>
|
||||
private void Next_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.actNDEFIndex < this.ndefList.Count - 1)
|
||||
{
|
||||
this.actNDEFIndex++;
|
||||
this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Event handler. Called by Prev for click events.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e"> Routed event information.</param>
|
||||
private void Prev_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.actNDEFIndex > 0)
|
||||
{
|
||||
this.actNDEFIndex--;
|
||||
this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Event handler. Called by Write for click events.</summary>
|
||||
/// <remarks>Stubbfel, 22.08.2013.</remarks>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e"> Routed event information.</param>
|
||||
private void Write_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.device.PublishBinaryMessage("NDEF:WriteTag", this.ndefList[this.actNDEFIndex].ToByteArray().AsBuffer(), this.PublishHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
readme.txt
Normal file
1
readme.txt
Normal file
@@ -0,0 +1 @@
|
||||
bla
|
||||
30
src/ndefpclib/Properties/AssemblyInfo.cs
Normal file
30
src/ndefpclib/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Resources;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über folgende
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die einer Assembly zugeordnet sind.
|
||||
[assembly: AssemblyTitle("ndefpclib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ndefpclib")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: NeutralResourcesLanguage("de")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// durch Einsatz von '*', wie in nachfolgendem Beispiel:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
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>
|
||||
28
src/ndefpclib/UNLICENSE.t.txt
Normal file
28
src/ndefpclib/UNLICENSE.t.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to [http://unlicense.org]
|
||||
|
||||
|
||||
|
||||
125
src/ndefpclib/message/NDEFMessage.cs
Normal file
125
src/ndefpclib/message/NDEFMessage.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
// namespace: ndefpclib.message
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.message
|
||||
{
|
||||
using ndefpclib.records;
|
||||
using ndefpclib.type;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
/// <summary> Ndef message. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public class NDEFMessage
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The records. </summary>
|
||||
private List<NDEFRecord> records;
|
||||
|
||||
/// <summary> Type of the message. </summary>
|
||||
private MsgType msgType;
|
||||
|
||||
#endregion
|
||||
|
||||
#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)
|
||||
{
|
||||
this.records = new List<NDEFRecord>();
|
||||
float recordsCount = (float)content.Length / NDEFRecord.MaxRecordPayLoad;
|
||||
NDEFRecord tmpRecord = null;
|
||||
this.msgType = type;
|
||||
|
||||
for (int i = 0; recordsCount > 0; i++)
|
||||
{
|
||||
tmpRecord = new NDEFShortRecord(type);
|
||||
|
||||
int recordsize = 255;
|
||||
if (content.Length < (i + 1) * recordsize)
|
||||
{
|
||||
recordsize = content.Length - (i * recordsize);
|
||||
}
|
||||
|
||||
tmpRecord.Payload = content.Substring(i * 255, recordsize);
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
tmpRecord.MB = NDEFRecord.NDEFFlags.MBSET;
|
||||
}
|
||||
|
||||
this.records.Add(tmpRecord);
|
||||
recordsCount--;
|
||||
}
|
||||
|
||||
this.records[this.records.IndexOf(tmpRecord)].ME = NDEFRecord.NDEFFlags.MESET;
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the NDEFMessage class. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
public NDEFMessage(byte[] array)
|
||||
{
|
||||
this.records = new List<NDEFRecord>();
|
||||
|
||||
NDEFRecord tmpRecord = null;
|
||||
for (int i = 0; i < array.Length; i += tmpRecord.RecordSize)
|
||||
{
|
||||
tmpRecord = new NDEFShortRecord(array, i);
|
||||
|
||||
this.records.Add(tmpRecord);
|
||||
}
|
||||
}
|
||||
|
||||
#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
|
||||
|
||||
/// <summary> Gets the content. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <returns> The content. </returns>
|
||||
public string GetContent()
|
||||
{
|
||||
string result = string.Empty;
|
||||
|
||||
foreach (NDEFRecord record in this.records)
|
||||
{
|
||||
result += record.Payload;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary> Converts this object to a byte array. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <returns> This object as a byte[]. </returns>
|
||||
public virtual byte[] ToByteArray()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
foreach (NDEFRecord record in this.records)
|
||||
{
|
||||
ms.Write(record.ToByteArray(), 0, record.RecordSize);
|
||||
}
|
||||
|
||||
return ms.ToArray();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
30
src/ndefpclib/message/Text/TextMessageUTF16.cs
Normal file
30
src/ndefpclib/message/Text/TextMessageUTF16.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the TextMessageUTF16 class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
public TextMessageUTF16(byte[] array) : base(array)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/ndefpclib/message/Text/TextMessageUTF8.cs
Normal file
29
src/ndefpclib/message/Text/TextMessageUTF8.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the TextMessageUTF8 class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
public TextMessageUTF8(byte[] array) : base(array)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
30
src/ndefpclib/message/Text/TextMessages.cs
Normal file
30
src/ndefpclib/message/Text/TextMessages.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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,byte encoding, string lang)
|
||||
: base(content, new TextType(encoding,lang))
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the TextMessage class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
public TextMessage(byte[] array) : base(array)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
61
src/ndefpclib/ndefpclib.csproj
Normal file
61
src/ndefpclib/ndefpclib.csproj
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ndefpclib</RootNamespace>
|
||||
<AssemblyName>ndefpclib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .NET Framework is automatically included -->
|
||||
<Content Include="UNLICENSE.t.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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\NDEFShortRecord.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="type\Const\Language.cs" />
|
||||
<Compile Include="type\MsgType.cs" />
|
||||
<Compile Include="type\Const\TextEncoding.cs" />
|
||||
<Compile Include="type\TextType.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<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.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
205
src/ndefpclib/record/NDEFRecord.cs
Normal file
205
src/ndefpclib/record/NDEFRecord.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
// namespace: ndefpclib.records
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.records
|
||||
{
|
||||
using ndefpclib.type;
|
||||
|
||||
/// <summary> Ndef record of a NDEFMessage. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public abstract class NDEFRecord
|
||||
{
|
||||
#region Members
|
||||
|
||||
/// <summary> The maximum record pay load. </summary>
|
||||
public const int MaxRecordPayLoad = 255;
|
||||
|
||||
/// <summary> Size of the type. </summary>
|
||||
protected const byte TypeSize = 0x01;
|
||||
|
||||
/// <summary> Type of the message. </summary>
|
||||
private MsgType msgType;
|
||||
|
||||
|
||||
/// <summary> Size of the encoded payload. </summary>
|
||||
private int encodedPayloadSize = -1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary> Initializes a new instance of the NDEFRecord class. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public NDEFRecord()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the NDEFRecord class. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
/// <param name="headerSize"> The size of the header. </param>
|
||||
/// <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];
|
||||
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
|
||||
|
||||
#region enum
|
||||
|
||||
/// <summary> Values that represent NDEFFlags. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public enum NDEFFlags
|
||||
{
|
||||
/// <summary>An Enum constant representing the UNSET option.</summary>
|
||||
UNSET = 0x00,
|
||||
|
||||
/// <summary>An Enum constant representing the Message begin option.</summary>
|
||||
MBSET = 0x80,
|
||||
|
||||
/// <summary>An Enum constant representing the Message end option.</summary>
|
||||
MESET = 0x40,
|
||||
|
||||
/// <summary>An Enum constant representing the CHUNK FLAG option.</summary>
|
||||
CFSET = 0x20,
|
||||
|
||||
/// <summary>An Enum constant representing the Short Record set option.</summary>
|
||||
SRSET = 0x10,
|
||||
|
||||
/// <summary>An Enum constant representing the ID length option.</summary>
|
||||
ILSET = 0x08,
|
||||
|
||||
/// <summary>An enum constant representing the tnfset option.</summary>
|
||||
TNFSET = 0x03
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary> Gets or sets the MBFlag. </summary>
|
||||
/// <value> The MBFlag. </value>
|
||||
public NDEFFlags MB { get; set; }
|
||||
|
||||
/// <summary> Gets or sets MEFlag. </summary>
|
||||
/// <value> The MEFlag . </value>
|
||||
public NDEFFlags ME { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the CFFlag. </summary>
|
||||
/// <value> The CFFlag. </value>
|
||||
public NDEFFlags CF { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the SRFlag. </summary>
|
||||
/// <value> The SRFlag. </value>
|
||||
public NDEFFlags SR { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the ILFlag. </summary>
|
||||
/// <value> The ILFlag. </value>
|
||||
public NDEFFlags IL { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the TNFField. </summary>
|
||||
/// <value> The TNFField. </value>
|
||||
public MsgType.TNFVAL TNF { get { return this.MsgType.TNFValue; } set { this.MsgType.TNFValue = value; } }
|
||||
|
||||
/// <summary> Gets or sets the type. </summary>
|
||||
/// <value> The type. </value>
|
||||
public MsgType.TYPEVAL Type { get { return this.MsgType.TypeValue; } set { this.MsgType.TypeValue = value; } }
|
||||
|
||||
/// <summary> Gets the format flags. </summary>
|
||||
/// <value> The format flags. </value>
|
||||
public byte FormatFlags
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte)((byte)this.TNF | ((byte)this.MB) | ((byte)this.ME) | ((byte)this.CF) | ((byte)this.SR) | ((byte)this.IL));
|
||||
}
|
||||
|
||||
protected set
|
||||
{
|
||||
this.TNF = (MsgType.TNFVAL)(value & (byte)NDEFFlags.TNFSET);
|
||||
this.MB = (NDEFFlags)(value & (byte)NDEFFlags.MBSET);
|
||||
this.ME = (NDEFFlags)(value & (byte)NDEFFlags.MESET);
|
||||
this.CF = (NDEFFlags)(value & (byte)NDEFFlags.CFSET);
|
||||
this.SR = (NDEFFlags)(value & (byte)NDEFFlags.SRSET);
|
||||
this.IL = (NDEFFlags)(value & (byte)NDEFFlags.ILSET);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the payload. </summary>
|
||||
/// <value> The payload. </value>
|
||||
public string Payload { get; set; }
|
||||
|
||||
/// <summary> Gets the size of the record. </summary>
|
||||
/// <value> The size of the record. </value>
|
||||
public int RecordSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.HeaderSize + this.EncodedPayloadSize + this.PayloadPraefix.Length;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the size of the encoded payload. </summary>
|
||||
/// <value> The size of the encoded payload. </value>
|
||||
public int EncodedPayloadSize
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.encodedPayloadSize >= 0)
|
||||
{
|
||||
return this.encodedPayloadSize;
|
||||
}
|
||||
else if (this.msgType != null && this.encodedPayloadSize < 0)
|
||||
{
|
||||
this.encodedPayloadSize = this.msgType.Encoder.GetByteCount(this.Payload);
|
||||
return this.encodedPayloadSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Payload.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the payload praefix. </summary>
|
||||
/// <value> The payload praefix. </value>
|
||||
public byte[] PayloadPraefix { get { return this.MsgType.PayloadPrefix; } set { this.MsgType.PayloadPrefix = value; } }
|
||||
|
||||
/// <summary> Gets or sets the size of the header. </summary>
|
||||
/// <value> The size of the header. </value>
|
||||
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
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <summary> Converts the record to a byte array. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <returns> This object as a byte[]. </returns>
|
||||
public abstract byte[] ToByteArray();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
77
src/ndefpclib/record/NDEFShortRecord.cs
Normal file
77
src/ndefpclib/record/NDEFShortRecord.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
// namespace: ndefpclib.records
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.records
|
||||
{
|
||||
using ndefpclib.message;
|
||||
using ndefpclib.type;
|
||||
using System.Text;
|
||||
|
||||
/// <summary> Ndef short record. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <seealso cref="T:ndefpclib.records.NDEFRecord"/>
|
||||
public class NDEFShortRecord : NDEFRecord
|
||||
{
|
||||
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public NDEFShortRecord()
|
||||
{
|
||||
this.HeaderSize = 4;
|
||||
this.SR = NDEFFlags.SRSET;
|
||||
this.IL = NDEFFlags.UNSET;
|
||||
this.CF = NDEFFlags.UNSET;
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <param name="array"> The array. </param>
|
||||
/// <param name="index"> (Optional) zero-based index of the. </param>
|
||||
public NDEFShortRecord(byte[] array, int index = 0)
|
||||
: base(array, 4)
|
||||
{
|
||||
this.SR = NDEFFlags.SRSET;
|
||||
this.IL = NDEFFlags.UNSET;
|
||||
this.CF = NDEFFlags.UNSET;
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the NDEFShortRecord class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="type"> The type. </param>
|
||||
public NDEFShortRecord(MsgType type)
|
||||
: base(type)
|
||||
{
|
||||
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.Payload);
|
||||
byte[] array = new byte[payloadAr.Length + this.HeaderSize + this.PayloadPraefix.Length];
|
||||
|
||||
array[0] = this.FormatFlags;
|
||||
array[1] = NDEFRecord.TypeSize;
|
||||
array[2] = (byte)(this.EncodedPayloadSize + this.PayloadPraefix.Length);
|
||||
array[3] = (byte)this.Type;
|
||||
|
||||
int i = this.HeaderSize;
|
||||
foreach (byte b in this.PayloadPraefix)
|
||||
{
|
||||
array[i] = b;
|
||||
i++;
|
||||
}
|
||||
foreach (byte b in payloadAr)
|
||||
{
|
||||
array[i] = b;
|
||||
i++;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/ndefpclib/type/Const/Language.cs
Normal file
17
src/ndefpclib/type/Const/Language.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
// namespace: ndefpclib.type.Const
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.type.Const
|
||||
{
|
||||
/// <summary> A language. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
public class Language
|
||||
{
|
||||
/// <summary> The de. </summary>
|
||||
public const string DE ="de";
|
||||
|
||||
/// <summary> The en. </summary>
|
||||
public const string EN = "en";
|
||||
}
|
||||
}
|
||||
36
src/ndefpclib/type/Const/TextEncoding.cs
Normal file
36
src/ndefpclib/type/Const/TextEncoding.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
// namespace: ndefpclib.type.Const
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.type.Const
|
||||
{
|
||||
using System.Text;
|
||||
|
||||
/// <summary> A text encoding. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
public class TextEncoding
|
||||
{
|
||||
/// <summary> The UTF 8. </summary>
|
||||
public const byte UTF8 = 0x02;
|
||||
|
||||
/// <summary> The UTF 16. </summary>
|
||||
public const byte UTF16 = 0x82;
|
||||
|
||||
/// <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(byte input)
|
||||
{
|
||||
switch (input)
|
||||
{
|
||||
case UTF8:
|
||||
return Encoding.UTF8;
|
||||
case UTF16:
|
||||
return Encoding.Unicode;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/ndefpclib/type/TextType.cs
Normal file
55
src/ndefpclib/type/TextType.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
// namespace: ndefpclib.type
|
||||
//
|
||||
// summary: .
|
||||
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
|
||||
{
|
||||
/// <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(byte encoding = TextEncoding.UTF8, string lang = Language.DE)
|
||||
{
|
||||
this.TNFValue = TNFVAL.WKT;
|
||||
this.TypeValue = TYPEVAL.TEXT;
|
||||
this.Encoder = TextEncoding.GetEncoding(encoding);
|
||||
|
||||
this.PayloadPrefix = new byte[3];
|
||||
this.PayloadPrefix[0] = (byte)encoding;
|
||||
this.PayloadPrefix[1] = (byte)lang[0];
|
||||
this.PayloadPrefix[2] = (byte)lang[1];
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
byte encoding = array[index + 4];
|
||||
Encoding encoder = TextEncoding.GetEncoding(encoding);
|
||||
|
||||
if (encoder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string lang = Encoding.UTF8.GetString(array, 5, 2);
|
||||
return new TextType(encoding, lang);
|
||||
}
|
||||
}
|
||||
}
|
||||
106
src/ndefpclib/type/msgType.cs
Normal file
106
src/ndefpclib/type/msgType.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
|
||||
// namespace: ndefpclib.type
|
||||
//
|
||||
// summary: .
|
||||
namespace ndefpclib.type
|
||||
{
|
||||
using System.Text;
|
||||
|
||||
/// <summary> A message type. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
public abstract class MsgType
|
||||
{
|
||||
|
||||
#region enum
|
||||
|
||||
/// <summary> Values that represent TYPEVAL. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public enum TYPEVAL
|
||||
{
|
||||
/// <summary>An enum constant representing the empty option.</summary>
|
||||
EMPTY = 0x00,
|
||||
|
||||
/// <summary>An enum constant representing the URL option.</summary>
|
||||
URL = 0x55,
|
||||
|
||||
/// <summary>An enum constant representing the text option.</summary>
|
||||
TEXT = 0x54
|
||||
}
|
||||
|
||||
/// <summary> Values that represent TNFVAL. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
public enum TNFVAL
|
||||
{
|
||||
/// <summary>An enum constant representing the empty option.</summary>
|
||||
EMPTY = 0x00,
|
||||
|
||||
/// <summary>An enum constant representing the Well-Know-Type option.</summary>
|
||||
WKT = 0x01,
|
||||
|
||||
/// <summary>An enum constant representing the MediaType option.</summary>
|
||||
MEDIATYPE = 0x02,
|
||||
|
||||
/// <summary>An enum constant representing the URI option.</summary>
|
||||
URI = 0x03,
|
||||
|
||||
/// <summary>An enum constant representing the NFCE option.</summary>
|
||||
NFCE = 0x04,
|
||||
|
||||
/// <summary>An enum constant representing the unknow option.</summary>
|
||||
unknow = 0x05,
|
||||
|
||||
/// <summary>An enum constant representing the unchanged option.</summary>
|
||||
UNCHANGED = 0x06,
|
||||
|
||||
/// <summary>An enum constant representing the reserved option.</summary>
|
||||
RESERVED = 0x07
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region property
|
||||
|
||||
/// <summary> Gets or sets the type value. </summary>
|
||||
/// <value> The type value. </value>
|
||||
public TYPEVAL TypeValue { get; set; }
|
||||
|
||||
/// <summary> Gets or sets the payload prefix. </summary>
|
||||
/// <value> The payload prefix. </value>
|
||||
public byte[] 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
|
||||
|
||||
#region methods
|
||||
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user