當前位置: 首頁>>代碼示例>>C#>>正文


C# Ndef.NdefRecord類代碼示例

本文整理匯總了C#中NdefLibrary.Ndef.NdefRecord的典型用法代碼示例。如果您正苦於以下問題:C# NdefRecord類的具體用法?C# NdefRecord怎麽用?C# NdefRecord使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NdefRecord類屬於NdefLibrary.Ndef命名空間,在下文中一共展示了NdefRecord類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: NdefHandoverErrorRecord

        /// <summary>
        /// Create a Handover Error record based on the record passed
        /// through the argument.
        /// </summary>
        /// <remarks>
        /// Internalizes and parses the payload of the original record.
        /// The original record has to be a Handover Error Record as well.
        /// </remarks>
        /// <param name="other">Record to copy into this Handover Error record.</param>
        /// <exception cref="NdefException">Thrown if attempting to create a Handover Error record
        /// based on an incompatible record type.</exception>
        public NdefHandoverErrorRecord(NdefRecord other)
            : base(other)
        {
            if (!IsRecordType(this))
                throw new NdefException(NdefExceptionMessages.ExInvalidCopy);

            ParsePayloadToData(_payload);
        }
開發者ID:CruzerBoon,項目名稱:ndef-nfc,代碼行數:19,代碼來源:NdefHandoverErrorRecord.cs

示例2: Main

        static void Main(string[] args)
        {
            // Dynamically construct some more NDEF records
            var spRecord = new NdefSpRecord
            {
                Uri = "http://andijakl.github.io/ndef-nfc/",
                NfcAction = NdefSpActRecord.NfcActionType.DoAction
            };
            spRecord.AddTitle(new NdefTextRecord { LanguageCode = "en", Text = "NFC Library" });
            spRecord.AddTitle(new NdefTextRecord { LanguageCode = "de", Text = "NFC Bibliothek" });
            NfcRecords.Add("SmartPoster", spRecord);

            // Ensure the path exists
            var tagsDirectory = Path.Combine(Environment.CurrentDirectory, FileDirectory);
            Directory.CreateDirectory(tagsDirectory);

            // Write tag contents to files
            foreach (var curNdefRecord in NfcRecords)
            {
                WriteTagFile(tagsDirectory, curNdefRecord.Key, curNdefRecord.Value);
            }

            // Multi-record file
            var record1 = new NdefUriRecord {Uri = "http://www.twitter.com"};
            var record2 = new NdefAndroidAppRecord {PackageName = "com.twitter.android"};
            var twoRecordsMsg = new NdefMessage {record1, record2};
            WriteTagFile(tagsDirectory, "TwoRecords", twoRecordsMsg);

            var record3 = new NdefRecord
            {
                TypeNameFormat = NdefRecord.TypeNameFormatType.ExternalRtd,
                Type = Encoding.UTF8.GetBytes("custom.com:myapp")
            };
            var threeRecordsMsg = new NdefMessage { record1, record3, record2 };
            WriteTagFile(tagsDirectory, "ThreeRecords", threeRecordsMsg);

            // Success message on output
            Console.WriteLine("Generated {0} tag files in {1}.", NfcRecords.Count, tagsDirectory);
            Debug.WriteLine("Generated {0} tag files in {1}.", NfcRecords.Count, tagsDirectory);
        }
開發者ID:Doluci,項目名稱:ndef-nfc,代碼行數:40,代碼來源:NfcTagGenerator.cs

示例3: NdefVcardRecordBase

 /// <summary>
 /// Create a MIME/vCard record based on the record passed
 /// through the argument.
 /// </summary>
 /// <remarks>
 /// Internalizes and parses the payload of the original record.
 /// The original record has to be a MIME/vCard Record as well.
 /// </remarks>
 /// <param name="other">Record to copy into this vCard record.</param>
 /// <exception cref="NdefException">Thrown if attempting to create a vCard record
 /// based on an incompatible record type.</exception>
 public NdefVcardRecordBase(NdefRecord other)
     : base(other)
 {
     if (!IsRecordType(this))
         throw new NdefException(NdefExceptionMessages.ExInvalidCopy);
 }
開發者ID:CruzerBoon,項目名稱:ndef-nfc,代碼行數:17,代碼來源:NdefVcardRecordBase.cs

示例4: NdefTelRecord

 /// <summary>
 /// Create a telephone record based on another telephone record, or Smart Poster / URI
 /// record that have a Uri set that corresponds to the tel: URI scheme.
 /// </summary>
 /// <param name="other">Other record to copy the data from.</param>
 public NdefTelRecord(NdefRecord other)
     : base(other)
 {
     ParseUriToData(Uri);
 }
開發者ID:CruzerBoon,項目名稱:ndef-nfc,代碼行數:10,代碼來源:NdefTelRecord.cs

示例5: IsRecordType

 /// <summary>
 /// Checks if the record sent via the parameter is indeed a Text record.
 /// Only checks the type and type name format, doesn't analyze if the
 /// payload is valid.
 /// </summary>
 /// <param name="record">Record to check.</param>
 /// <returns>True if the record has the correct type and type name format
 /// to be a Text record, false if it's a different record.</returns>
 public static bool IsRecordType(NdefRecord record)
 {
     if (record?.Type == null) return false;
     return (record.TypeNameFormat == TypeNameFormatType.NfcRtd && record.Type.SequenceEqual(TextType));
 }
開發者ID:SpivEgin,項目名稱:ndef-nfc,代碼行數:13,代碼來源:NdefTextRecord.cs

示例6: ConvertTypeNameFormatToString

 private string ConvertTypeNameFormatToString(NdefRecord.TypeNameFormatType tnf)
 {
     // Each record contains a type name format, which defines which format
     // the type name is actually in.
     // This method converts the constant to a human-readable string.
     string tnfString;
     switch (tnf)
     {
         case NdefRecord.TypeNameFormatType.Empty:
             tnfString = "Empty NDEF record (does not contain a payload)";
             break;
         case NdefRecord.TypeNameFormatType.NfcRtd:
             tnfString = "NFC RTD Specification";
             break;
         case NdefRecord.TypeNameFormatType.Mime:
             tnfString = "RFC 2046 (Mime)";
             break;
         case NdefRecord.TypeNameFormatType.Uri:
             tnfString = "RFC 3986 (Url)";
             break;
         case NdefRecord.TypeNameFormatType.ExternalRtd:
             tnfString = "External type name";
             break;
         case NdefRecord.TypeNameFormatType.Unknown:
             tnfString = "Unknown record type; should be treated similar to content with MIME type 'application/octet-stream' without further context";
             break;
         case NdefRecord.TypeNameFormatType.Unchanged:
             tnfString = "Unchanged (partial record)";
             break;
         case NdefRecord.TypeNameFormatType.Reserved:
             tnfString = "Reserved";
             break;
         default:
             tnfString = "Unknown";
             break;
     }
     return tnfString;
 }
開發者ID:Doluci,項目名稱:ndef-nfc,代碼行數:38,代碼來源:MainPage.xaml.cs

示例7: NdefIcalendarRecordBase

 /// <summary>
 /// Create a MIME/iCal record based on the record passed
 /// through the argument.
 /// </summary>
 /// <remarks>
 /// Internalizes and parses the payload of the original record.
 /// The original record has to be a MIME/iCal Record as well.
 /// </remarks>
 /// <param name="other">Record to copy into this iCal record.</param>
 /// <exception cref="NdefException">Thrown if attempting to create a iCal record
 /// based on an incompatible record type.</exception>
 protected NdefIcalendarRecordBase(NdefRecord other)
     : base(other)
 {
     if (!IsRecordType(this))
         throw new NdefException(NdefExceptionMessages.ExInvalidCopy);
 }
開發者ID:CruzerBoon,項目名稱:ndef-nfc,代碼行數:17,代碼來源:NdefIcalendarRecordBase.cs

示例8: NdefSpRecord

        /// <summary>
        /// Create a Smart Poster record based on the record passed
        /// through the argument.
        /// </summary>
        /// <remarks>
        /// Internalizes and parses the payload of the original record.
        /// The original record can be a Smart Poster or a URI record.
        /// </remarks>
        /// <param name="other">Record to copy into this smart poster record.</param>
        /// <exception cref="NdefException">Thrown if attempting to create a Smart Poster
        /// based on an incompatible record type.</exception>
        public NdefSpRecord(NdefRecord other)
            : base(other)
        {
            if (TypeNameFormat != TypeNameFormatType.NfcRtd)
                throw new NdefException(NdefExceptionMessages.ExInvalidCopy);
            if (_type.SequenceEqual(SmartPosterType))
            {
                // Other record was a Smart Poster, so parse and internalize the Sp payload
                ParsePayloadToData(_payload);
            }
            else if (_type.SequenceEqual(NdefUriRecord.UriType))
            {
                // Create Smart Poster based on URI record
                RecordUri = new NdefUriRecord(other) {Id = null};
                // Set type of this instance to Smart Poster
                _type = new byte[SmartPosterType.Length];
                Array.Copy(SmartPosterType, _type, SmartPosterType.Length);
            }
            else
            {
                throw new NdefException(NdefExceptionMessages.ExInvalidCopy);
            }

        }
開發者ID:Doluci,項目名稱:ndef-nfc,代碼行數:35,代碼來源:NdefSpRecord.cs

示例9: IsRecordType

 /// <summary>
 /// Checks if the record sent via the parameter is indeed a Windows Phone Settings record.
 /// </summary>
 /// <param name="record">Record to check.</param>
 /// <returns>True if the record has the correct type and type name format
 /// to be a WP Settings record + if its URI equals one of the allowed
 /// scheme names. False if it's a different record.</returns>
 public static new bool IsRecordType(NdefRecord record)
 {
     if (!NdefUriRecord.IsRecordType(record)) return false;
     var testRecord = new NdefUriRecord(record);
     return testRecord.Uri != null && SettingsSchemes.Any(curScheme => testRecord.Uri.Equals(curScheme.Value));
 }
開發者ID:rossdargan,項目名稱:MvxPlugins,代碼行數:13,代碼來源:NdefWpSettingsRecord.cs

示例10: PublishRecord

        private void PublishRecord(NdefRecord record, bool writeToTag)
        {
            if (_device == null) return;
            // Make sure we're not already publishing another message
            StopPublishingMessage(false);
            // Wrap the NDEF record into an NDEF message
            var message = new NdefMessage { record };
            // Convert the NDEF message to a byte array
            var msgArray = message.ToByteArray();
            // Publish the NDEF message to a tag or to another device, depending on the writeToTag parameter
            // Save the publication ID so that we can cancel publication later
            _publishingMessageId = _device.PublishBinaryMessage((writeToTag ? "NDEF:WriteTag" : "NDEF"), msgArray.AsBuffer(), MessageWrittenHandler);
            // Update status text for UI
            SetStatusOutput(string.Format((writeToTag ? AppResources.StatusWriteToTag : AppResources.StatusWriteToDevice), msgArray.Length, _publishingMessageId));
            // Update enabled / disabled state of buttons in the User Interface
            SetStatusOutput(string.Format("You said \"{0}\"\nPlease touch a tag to write the message.", recordresult));
           



            recordresult = "";
            UpdateUiForNfcStatus();
        }
開發者ID:RyanAClark,項目名稱:Easy-NFC,代碼行數:23,代碼來源:MainPage.xaml.cs

示例11: PublishRecord

     //   private Windows.UI.Core.CoreDispatcher _dispatcher =
     //Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;

     //   private async void ProximityDeviceArrived(object sender)
     //   {
     //       await _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
     //       () =>
     //       {
     //           StatusOutput.Text += "Proximate device arrived.\n";
     //       });
     //   }

     //   private async void ProximityDeviceDeparted(object sender)
     //   {
     //       await _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
     //       () =>
     //       {
     //           StatusOutput.Text += "Proximate device departed.\n";
     //       });
     //   }

        private void PublishRecord(NdefRecord record, bool writeToTag)
        {
            if (_device == null) return;
            // Make sure we're not already publishing another message
            StopPublishingMessage(false);
            // Wrap the NDEF record into an NDEF message
            var message = new NdefMessage { record };
            // Convert the NDEF message to a byte array
            var msgArray = message.ToByteArray();
            // Publish the NDEF message to a tag or to another device, depending on the writeToTag parameter
            // Save the publication ID so that we can cancel publication later
            _publishingMessageId = _device.PublishBinaryMessage((writeToTag ? "NDEF:WriteTag" : "NDEF"), msgArray.AsBuffer(), MessageWrittenHandler);
            // Update status text for UI
           //_publishingMessageId = -1;
            SetStatusOutput(string.Format((writeToTag ? AppResources.StatusWriteToTag : AppResources.StatusWriteToDevice), msgArray.Length, _publishingMessageId));
           
        }
開發者ID:roxvicky,項目名稱:SmartParking,代碼行數:38,代碼來源:eTags.xaml.cs

示例12: NdefVcardRecord

 /// <summary>
 /// Creates a new instance of an NdefVcardRecord and imports
 /// the payload into the ContactData instance.
 /// </summary>
 /// <param name="other">An NDEF record that contains
 /// valid vCard data as its payload and has the right type information.</param>
 public NdefVcardRecord(NdefRecord other) : base(other)
 {
     ContactData = ParseDataToContact(_payload);
 }
開發者ID:Doluci,項目名稱:ndef-nfc,代碼行數:10,代碼來源:NdefVcardRecord.cs

示例13: NdefNearSpeakRecord

 /// <summary>
 /// Create a telephone record based on another telephone record, or Smart Poster / URI
 /// record that have a Uri set that corresponds to the tel: URI scheme.
 /// </summary>
 /// <param name="other">Other record to copy the data from.</param>
 public NdefNearSpeakRecord(NdefRecord other)
     : base(other)
 {
     ParseUriToData(Uri);
 }
開發者ID:rossdargan,項目名稱:MvxPlugins,代碼行數:10,代碼來源:NdefNearSpeakRecord.cs

示例14: IsRecordType

 /// <summary>
 /// Checks if the record sent via the parameter is indeed a NearSpeak record.
 /// Only checks the type and type name format, doesn't analyze if the
 /// payload is valid.
 /// </summary>
 /// <param name="record">Record to check.</param>
 /// <returns>True if the record has the correct type and type name format
 /// to be a NearSpeak record, false if it's a different record.</returns>
 public static new bool IsRecordType(NdefRecord record)
 {
     if (!NdefUriRecord.IsRecordType(record)) return false;
     var testRecord = new NdefUriRecord(record);
     if (testRecord.Uri == null || testRecord.Uri.Length < NearSpeakScheme.Length + 3)
         return false;
     return testRecord.Uri.StartsWith(NearSpeakScheme);
 }
開發者ID:rossdargan,項目名稱:MvxPlugins,代碼行數:16,代碼來源:NdefNearSpeakRecord.cs

示例15: WriteTagFile

 private static void WriteTagFile(string pathName, string tagName, NdefRecord ndefRecord)
 {
     WriteTagFile(pathName, tagName, new NdefMessage { ndefRecord });
 }
開發者ID:Doluci,項目名稱:ndef-nfc,代碼行數:4,代碼來源:NfcTagGenerator.cs


注:本文中的NdefLibrary.Ndef.NdefRecord類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。