Merge branch 'feature/addnfclib' into develop
This commit is contained in:
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
[submodule "CampusAppWP8/NfcLib"]
|
||||
path = CampusAppWP8/NfcLib
|
||||
url = git@141.43.76.143:repos/bare/nfclib.git
|
||||
branch = develop
|
||||
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppDLL", "CampusAppDL
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CampusAppWP8ScheduledTaskAgent", "CampusAppWP8ScheduledTaskAgent\CampusAppWP8ScheduledTaskAgent.csproj", "{2A51FA6C-791B-4935-B869-FDBA9ED774D7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ndefpclib", "NfcLib\src\ndefpclib\ndefpclib.csproj", "{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -163,6 +165,22 @@ Global
|
||||
{2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.ActiveCfg = Release|x86
|
||||
{2A51FA6C-791B-4935-B869-FDBA9ED774D7}.Release|x86.Build.0 = Release|x86
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|Win32.ActiveCfg = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -251,9 +251,7 @@
|
||||
<DependentUpon>WeekViewDay.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\Lui\Tiles\TileCreator.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFMessage.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFRecord.cs" />
|
||||
<Compile Include="Utility\NDEF\NDEFShortRecord.cs" />
|
||||
<Compile Include="Utility\NDEF\BTUTagMessage.cs" />
|
||||
<Compile Include="Pages\Dev\NFC.xaml.cs">
|
||||
<DependentUpon>NFC.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -693,6 +691,10 @@
|
||||
<Project>{67D80BE2-0FB7-44C8-A495-7D44FC2AC262}</Project>
|
||||
<Name>CampusAppWPortalLib8</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\NfcLib\src\ndefpclib\ndefpclib.csproj">
|
||||
<Project>{01C6941E-AAF1-4324-BA54-B4A53BC66ADF}</Project>
|
||||
<Name>ndefpclib</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
|
||||
@@ -493,7 +493,7 @@ namespace CampusAppWP8.Pages.Campusmap
|
||||
this.device.StopSubscribingForMessage(message.SubscriptionId);
|
||||
var ndefMessage = message.Data;
|
||||
byte[] data = ndefMessage.ToArray();
|
||||
NDEFMessage ndef = new NDEFMessage(data);
|
||||
BTUTagMessage ndef = new BTUTagMessage(data);
|
||||
|
||||
// search for placeId
|
||||
string nfcContent = ndef.GetContent();
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace CampusAppWP8.Pages.Dev
|
||||
private int actNDEFIndex;
|
||||
|
||||
/// <summary> List of ndefs. </summary>
|
||||
private List<NDEFMessage> ndefList;
|
||||
private List<BTUTagMessage> ndefList;
|
||||
|
||||
/// <summary> The file. </summary>
|
||||
private PlacesFile file;
|
||||
@@ -82,12 +82,12 @@ namespace CampusAppWP8.Pages.Dev
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
private void FileIsReady()
|
||||
{
|
||||
this.ndefList = new List<NDEFMessage>();
|
||||
this.ndefList = new List<BTUTagMessage>();
|
||||
|
||||
// MapModel map = new CBMainMapModel(this.file.Model.Places.ToList());
|
||||
foreach (PlaceModel place in this.file.Model.Places.ToList())
|
||||
{
|
||||
this.ndefList.Add(new NDEFMessage(place.ToNfcString(), NDEFMessage.TYPEVAL.TEXT));
|
||||
this.ndefList.Add(new BTUTagMessage(place.ToNfcString()));
|
||||
}
|
||||
|
||||
this.Writecontent.Text = this.ndefList[this.actNDEFIndex].GetContent();
|
||||
@@ -113,7 +113,7 @@ namespace CampusAppWP8.Pages.Dev
|
||||
var ndefMessage = message.Data;
|
||||
byte[] testa = ndefMessage.ToArray();
|
||||
|
||||
NDEFMessage ndef = new NDEFMessage(testa);
|
||||
BTUTagMessage ndef = new BTUTagMessage(testa);
|
||||
this.Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
|
||||
}
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace CampusAppWP8.Pages.PlaceNews
|
||||
var ndefMessage = message.Data;
|
||||
byte[] data = ndefMessage.ToArray();
|
||||
|
||||
NDEFMessage ndef = new NDEFMessage(data);
|
||||
BTUTagMessage ndef = new BTUTagMessage(data);
|
||||
string nfcContent = ndef.GetContent();
|
||||
string pid = Wp8StringManager.FilterPlaceIdinNFCResultString(nfcContent.Trim());
|
||||
if (pid != null)
|
||||
|
||||
@@ -382,7 +382,7 @@ namespace CampusAppWP8.Pages
|
||||
this.device.StopSubscribingForMessage(message.SubscriptionId);
|
||||
var ndefMessage = message.Data;
|
||||
byte[] data = ndefMessage.ToArray();
|
||||
NDEFMessage ndef = new NDEFMessage(data);
|
||||
BTUTagMessage ndef = new BTUTagMessage(data);
|
||||
string nfcContent = ndef.GetContent();
|
||||
if (nfcContent == null)
|
||||
{
|
||||
|
||||
20
CampusAppWP8/CampusAppWP8/Utility/NDEF/BTUTagMessage.cs
Normal file
20
CampusAppWP8/CampusAppWP8/Utility/NDEF/BTUTagMessage.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CampusAppWP8.Utility.NDEF
|
||||
{
|
||||
public class BTUTagMessage : ndefpclib.message.Text.TextMessageUTF8
|
||||
{
|
||||
public BTUTagMessage(string content): base(content,ndefpclib.type.Const.Language.DE)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BTUTagMessage(byte[] array) : base(array)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +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,191 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NDEFRecord.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the ndef record class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
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 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,73 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="NDEFShortRecord.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>15.10.2013</date>
|
||||
// <summary>Implements the ndef short record class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.NDEF
|
||||
{
|
||||
using System.Text;
|
||||
|
||||
/// <summary> Ndef short record. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWP8.Utility.NDEF.NDEFRecord"/>
|
||||
public class NDEFShortRecord : NDEFRecord
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Method
|
||||
|
||||
/// <summary> Converts this NDEFShortRecord to a byte array. </summary>
|
||||
/// <remarks> Stubbfel, 21.08.2013. </remarks>
|
||||
/// <seealso cref="M:CampusAppWP8.Utility.NDEF.NDEFRecord.ToByteArray()"/>
|
||||
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;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,44 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="GeoMapPoint.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Stubbfel</author>
|
||||
// <date>23.10.2013</date>
|
||||
// <summary>Implements the geo map point class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWPortalLib8.Model.Utility
|
||||
{
|
||||
using System.Globalization;
|
||||
|
||||
/// <summary> A geo map point. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWPortalLib8.Model.Utility.MapPoint"/>
|
||||
public class GeoMapPoint : MapPoint
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary> Initializes a new instance of the GeoMapPoint class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
public GeoMapPoint()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the GeoMapPoint class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="latitude"> The latitude. </param>
|
||||
/// <param name="longitude"> The longitude. </param>
|
||||
/// <param name="timestamp"> The timestamp. </param>
|
||||
public GeoMapPoint(double latitude, double longitude, long timestamp)
|
||||
: base(longitude, latitude)
|
||||
{
|
||||
this.Timestamp = timestamp;
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the GeoMapPoint class. </summary>
|
||||
/// <remarks> Stubbfel, 23.10.2013. </remarks>
|
||||
/// <param name="latitude"> The latitude. </param>
|
||||
/// <param name="longitude"> The longitude. </param>
|
||||
/// <param name="timestamp"> The timestamp. </param>
|
||||
public GeoMapPoint(string latitude, string longitude, string timestamp)
|
||||
{
|
||||
double lat;
|
||||
@@ -34,7 +60,8 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
|
||||
#region Property
|
||||
|
||||
[DataMember]
|
||||
/// <summary> Gets or sets the latitude. </summary>
|
||||
/// <value> The latitude. </value>
|
||||
public double Latitude
|
||||
{
|
||||
get
|
||||
@@ -48,7 +75,8 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
/// <summary> Gets or sets the longitude. </summary>
|
||||
/// <value> The longitude. </value>
|
||||
public double Longitude
|
||||
{
|
||||
get
|
||||
@@ -62,7 +90,8 @@ namespace CampusAppWPortalLib8.Model.Utility
|
||||
}
|
||||
}
|
||||
|
||||
[DataMember]
|
||||
/// <summary> Gets or sets the timestamp. </summary>
|
||||
/// <value> The timestamp. </value>
|
||||
public long Timestamp { get; set; }
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user