add toNfcString
This commit is contained in:
@@ -83,5 +83,14 @@ namespace CampusAppWP8.Model.GeoDb
|
||||
/// <value>The services.</value>
|
||||
[XmlElement("placeService")]
|
||||
public ObservableCollection<PlaceService> Services { get; set; }
|
||||
|
||||
/// <summary>Converts this object to a nfc string.</summary>
|
||||
/// <remarks>Stubbfel, 21.08.2013.</remarks>
|
||||
/// <returns>This object as a string.</returns>
|
||||
public string ToNfcString()
|
||||
{
|
||||
string nfcStr = "{\"pid\":\"" + this.PlaceId + "\",\"parent\":\"" + this.ParentId + "\"}";
|
||||
return nfcStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ using Windows.Networking.Proximity;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using CampusAppWP8.Utility.NDEF;
|
||||
using Windows.Storage.Streams;
|
||||
using CampusAppWP8.Model.GeoDb;
|
||||
|
||||
|
||||
namespace CampusAppWP8.Pages.Dev
|
||||
@@ -61,7 +62,7 @@ namespace CampusAppWP8.Pages.Dev
|
||||
|
||||
this.device.StopSubscribingForMessage(message.SubscriptionId);
|
||||
|
||||
NDEFMessage ndef = new NDEFMessage("test", NDEFMessage.TYPEVAL.TEXT);
|
||||
NDEFMessage ndef = new NDEFMessage((new PlaceModel() { PlaceId = "1"}).ToNfcString(), NDEFMessage.TYPEVAL.TEXT);
|
||||
byte[] ndefB = ndef.ToByteArray();
|
||||
IBuffer buffer = ndefB.AsBuffer();
|
||||
device.PublishBinaryMessage("NDEF:WriteTag", ndef.ToByteArray().AsBuffer(), publishHandler);
|
||||
@@ -82,8 +83,8 @@ namespace CampusAppWP8.Pages.Dev
|
||||
byte[] testa = NDefMessage.ToArray();
|
||||
|
||||
NDEFMessage ndef = new NDEFMessage(testa);
|
||||
string c = ndef.GetContent();
|
||||
// NDEFRecord test = new NDEFRecord(testa);
|
||||
Dispatcher.BeginInvoke(new Action(() => MessageBox.Show(ndef.GetContent())));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace CampusAppWP8.Utility.NDEF
|
||||
/// <returns>This object as a byte[].</returns>
|
||||
public override byte[] ToByteArray()
|
||||
{
|
||||
byte[] payloadAr = Encoding.UTF8.GetBytes(this.PayloadPraefix + Payload);
|
||||
byte[] payloadAr = Encoding.UTF8.GetBytes(this.PayloadPraefix + this.Payload);
|
||||
byte[] array = new byte[payloadAr.Length + this.HeaderSize];
|
||||
|
||||
array[0] = this.FormatFlags;
|
||||
|
||||
Reference in New Issue
Block a user