private static void FromDeviceTouchUrl(PlatformNfcTagRecord nfcTagRecord, string url) { nfcTagRecord.Url = url; if (!string.IsNullOrWhiteSpace(url)) { var match = NfcTouchUrlRegex.Match(url); if (match != null && match.Success) { var domainGroup = match.Groups["domain"]; if (domainGroup != null) { nfcTagRecord.Domain = domainGroup.Value; } var deviceIdGroup = match.Groups["deviceId"]; if (deviceIdGroup != null) { nfcTagRecord.DeviceId = deviceIdGroup.Value; } } } }
public static PlatformNfcTagRecord ToPlatformNfcTagRecord(Stack <NdefRecord> ndefRecords) { var ndefRecord = ndefRecords.Peek(); if (ndefRecord != null) { var nfcUriRecord = ndefRecord as NfcUriRecord; if (nfcUriRecord != null) { if (nfcUriRecord.UriPrefix == NfcUriRecord.Prefix.http || nfcUriRecord.UriPrefix == NfcUriRecord.Prefix.https || nfcUriRecord.UriPrefix == NfcUriRecord.Prefix.httpswww || nfcUriRecord.UriPrefix == NfcUriRecord.Prefix.httpwww) { var platformNfcTagRecord = PlatformNfcTagRecord.FromDeviceTouchUrl(nfcUriRecord.ToString()); if (platformNfcTagRecord != null) { ndefRecords.Pop(); return(platformNfcTagRecord); } } } } return(null); }
public static PlatformNfcTagRecord FromDeviceTouchUrl(string url) { if (!string.IsNullOrWhiteSpace(url)) { var nfcTagRecord = new PlatformNfcTagRecord(); FromDeviceTouchUrl(nfcTagRecord, url); if (nfcTagRecord.IsValid()) { return(nfcTagRecord); } else { return(null); } } return(null); }