本文整理汇总了C#中net.named_data.jndn.Interest.unsetLink方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.unsetLink方法的具体用法?C# Interest.unsetLink怎么用?C# Interest.unsetLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Interest
的用法示例。
在下文中一共展示了Interest.unsetLink方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: testInterestLinkObject
////////////////////////////////////
// Tests from ndn-cxx interest.t.cpp
////////////////////////////////////
public void testInterestLinkObject()
{
Link link1 = new Link();
link1.setName(new Name("test"));
link1.addDelegation(10, new Name("/test1"));
link1.addDelegation(20, new Name("/test2"));
link1.addDelegation(100, new Name("/test3"));
try {
keyChain.sign(link1, certificateName);
} catch (SecurityException ex) {
Assert.Fail(ex.Message);
}
Blob linkEncoding = link1.wireEncode();
Interest interestA = new Interest();
Link link2 = null;
try {
interestA.setLinkWireEncoding(linkEncoding);
link2 = interestA.getLink();
} catch (Exception ex_0) {
Assert.Fail(ex_0.Message);
}
Assert.AssertTrue(link2 != null);
Name name = link2.getName();
Assert.AssertEquals(new Name("test"), name);
DelegationSet delegations = link2.getDelegations();
for (int i = 0; i < delegations.size(); ++i) {
if (i == 0) {
Assert.AssertEquals(10, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test1"), delegations.get(i).getName());
}
if (i == 1) {
Assert.AssertEquals(20, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test2"), delegations.get(i).getName());
}
if (i == 2) {
Assert.AssertEquals(100, delegations.get(i).getPreference());
Assert.AssertEquals(new Name("/test3"), delegations.get(i).getName());
}
}
interestA.setLinkWireEncoding(new Blob(LINK, false));
Link link3 = null;
try {
link3 = interestA.getLink();
} catch (Exception ex_1) {
Assert.Fail(ex_1.Message);
}
Assert.AssertEquals(2, link3.getDelegations().size());
interestA.unsetLink();
Assert.AssertEquals(false, interestA.hasLink());
}
示例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);
}