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


C# Interest.setSelectedDelegationIndex方法代碼示例

本文整理匯總了C#中net.named_data.jndn.Interest.setSelectedDelegationIndex方法的典型用法代碼示例。如果您正苦於以下問題:C# Interest.setSelectedDelegationIndex方法的具體用法?C# Interest.setSelectedDelegationIndex怎麽用?C# Interest.setSelectedDelegationIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.named_data.jndn.Interest的用法示例。


在下文中一共展示了Interest.setSelectedDelegationIndex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: testInterestSelectedDelegation

        public void testInterestSelectedDelegation()
        {
            Link link = new Link();
            link.setName(new Name("test"));
            link.addDelegation(10, new Name("/test1"));
            link.addDelegation(20, new Name("/test2"));
            link.addDelegation(100, new Name("/test3"));

            try {
                keyChain.sign(link, certificateName);
            } catch (SecurityException ex) {
                Assert.Fail(ex.Message);
            }

            Blob linkEncoding = link.wireEncode();

            Interest interestA = new Interest();
            interestA.setLinkWireEncoding(linkEncoding);
            Assert.AssertTrue(interestA.getSelectedDelegationIndex() < 0);

            interestA.setSelectedDelegationIndex(link.getDelegations().find(
                    new Name("test2")));
            Assert.AssertTrue(interestA.getSelectedDelegationIndex() >= 0);
            Link link2 = null;
            try {
                link2 = interestA.getLink();
            } catch (Exception ex_0) {
                Assert.Fail(ex_0.Message);
            }
            Assert.AssertEquals(
                    new Name("test2"),
                    link2.getDelegations()
                            .get(interestA.getSelectedDelegationIndex()).getName());

            interestA.setSelectedDelegationIndex(-1);
            Assert.AssertTrue(interestA.getSelectedDelegationIndex() < 0);
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:37,代碼來源:TestLink.cs

示例2: decodeInterest

        /// <summary>
        /// Decode input as an interest in  NDN-TLV and set the fields of the interest
        /// object.
        /// </summary>
        ///
        /// <param name="interest">The Interest object whose fields are updated.</param>
        /// <param name="input"></param>
        /// <param name="signedPortionBeginOffset">name component and ends just before the final name component (which is assumed to be a signature for a signed interest).</param>
        /// <param name="signedPortionEndOffset">name component and ends just before the final name component (which is assumed to be a signature for a signed interest).</param>
        /// <param name="copy">unchanged while the Blob values are used.</param>
        /// <exception cref="EncodingException">For invalid encoding.</exception>
        public override void decodeInterest(Interest interest, ByteBuffer input,
				int[] signedPortionBeginOffset, int[] signedPortionEndOffset,
				bool copy)
        {
            TlvDecoder decoder = new TlvDecoder(input);

            int endOffset = decoder.readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.Interest);
            decodeName(interest.getName(), signedPortionBeginOffset,
                    signedPortionEndOffset, decoder, copy);
            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Selectors, endOffset))
                decodeSelectors(interest, decoder, copy);
            // Require a Nonce, but don't force it to be 4 bytes.
            ByteBuffer nonce = decoder.readBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.Nonce);
            interest.setInterestLifetimeMilliseconds(decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.InterestLifetime,
                            endOffset));

            if (decoder.peekType(net.named_data.jndn.encoding.tlv.Tlv.Data, endOffset)) {
                // Get the bytes of the Link TLV.
                int linkBeginOffset = decoder.getOffset();
                int linkEndOffset = decoder.readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.Data);
                decoder.seek(linkEndOffset);

                interest.setLinkWireEncoding(
                        new Blob(decoder.getSlice(linkBeginOffset, linkEndOffset),
                                copy), this);
            } else
                interest.unsetLink();
            interest.setSelectedDelegationIndex((int) decoder
                    .readOptionalNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.SelectedDelegation,
                            endOffset));
            if (interest.getSelectedDelegationIndex() >= 0 && !interest.hasLink())
                throw new EncodingException(
                        "Interest has a selected delegation, but no link object");

            // Set the nonce last because setting other interest fields clears it.
            interest.setNonce(new Blob(nonce, copy));

            decoder.finishNestedTlvs(endOffset);
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:51,代碼來源:Tlv0_2WireFormat.cs


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