本文整理汇总了C#中net.named_data.jndn.Name.wireEncode方法的典型用法代码示例。如果您正苦于以下问题:C# Name.wireEncode方法的具体用法?C# Name.wireEncode怎么用?C# Name.wireEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.named_data.jndn.Name
的用法示例。
在下文中一共展示了Name.wireEncode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addMember
/// <summary>
/// Add a new member with the given key named keyName into a schedule named
/// scheduleName. The member's identity name is keyName.getPrefix(-1).
/// </summary>
///
/// <param name="scheduleName">The schedule name.</param>
/// <param name="keyName">The name of the key.</param>
/// <param name="key">A Blob of the public key DER.</param>
/// <exception cref="GroupManagerDb.Error">If there's no schedule named scheduleName, ifthe member's identity name already exists, or other database error.</exception>
public override void addMember(String scheduleName, Name keyName, Blob key)
{
int scheduleId = getScheduleId(scheduleName);
if (scheduleId == -1)
throw new GroupManagerDb.Error("The schedule does not exist");
// Needs to be changed in the future.
Name memberName = keyName.getPrefix(-1);
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.INSERT_addMember);
statement.setInt(1, scheduleId);
statement.setBytes(2, memberName.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
statement.setBytes(3, keyName.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
statement.setBytes(4, key.getImmutableArray());
try {
statement.executeUpdate();
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.addMember: SQLite error: "
+ exception);
}
}
示例2: hasMember
////////////////////////////////////////////////////// Member management.
/// <summary>
/// Check if there is a member with the given identity name.
/// </summary>
///
/// <param name="identity">The member's identity name.</param>
/// <returns>True if there is a member.</returns>
/// <exception cref="GroupManagerDb.Error">for a database error.</exception>
public override bool hasMember(Name identity)
{
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.SELECT_hasMember);
statement.setBytes(1, identity.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
try {
SqlDataReader result = statement.executeQuery();
if (result.NextResult())
return true;
else
return false;
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.hasMember: SQLite error: "
+ exception);
}
}
示例3: updateMemberSchedule
/// <summary>
/// Change the name of the schedule for the given member's identity name.
/// </summary>
///
/// <param name="identity">The member's identity name.</param>
/// <param name="scheduleName">The new schedule name.</param>
/// <exception cref="GroupManagerDb.Error">if there's no member with the given identityname in the database, or there's no schedule named scheduleName, or otherdatabase error.</exception>
public override void updateMemberSchedule(Name identity, String scheduleName)
{
int scheduleId = getScheduleId(scheduleName);
if (scheduleId == -1)
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.updateMemberSchedule: The schedule does not exist");
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.UPDATE_updateMemberSchedule);
statement.setInt(1, scheduleId);
statement.setBytes(2, identity.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
try {
statement.executeUpdate();
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.updateMemberSchedule: SQLite error: "
+ exception);
}
}
示例4: getMemberSchedule
/// <summary>
/// Get the name of the schedule for the given member's identity name.
/// </summary>
///
/// <param name="identity">The member's identity name.</param>
/// <returns>The name of the schedule.</returns>
/// <exception cref="GroupManagerDb.Error">if there's no member with the given identityname in the database, or other database error.</exception>
public override String getMemberSchedule(Name identity)
{
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.SELECT_getMemberSchedule);
statement.setBytes(1, identity.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
try {
SqlDataReader result = statement.executeQuery();
if (result.NextResult())
return result.getString(1);
else
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.getMemberSchedule: Cannot get the result from the database");
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.getMemberSchedule: SQLite error: "
+ exception);
}
}
示例5: deleteMember
/// <summary>
/// Delete a member with the given identity name. If there is no member with
/// the identity name, then do nothing.
/// </summary>
///
/// <param name="identity">The member's identity name.</param>
/// <exception cref="GroupManagerDb.Error">for a database error.</exception>
public override void deleteMember(Name identity)
{
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.DELETE_deleteMember);
statement.setBytes(1, identity.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
try {
statement.executeUpdate();
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new GroupManagerDb.Error(
"Sqlite3GroupManagerDb.deleteMember: SQLite error: "
+ exception);
}
}
示例6: testEncodeDecode
public void testEncodeDecode()
{
Name name = new Name("/local/ndn/prefix");
Blob encoding = name.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get());
Assert.AssertTrue(encoding.equals(new Blob(TEST_NAME, false)));
Name decodedName = new Name();
try {
decodedName.wireDecode(new Blob(TEST_NAME, false),
net.named_data.jndn.encoding.TlvWireFormat.get());
} catch (EncodingException ex) {
Assert.Fail("Can't decode TEST_NAME");
}
Assert.AssertEquals(decodedName, name);
// Test ImplicitSha256Digest.
Name name2 = new Name(
"/local/ndn/prefix/sha256digest="
+ "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");
Blob encoding2 = name2.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get());
Assert.AssertTrue(encoding2.equals(new Blob(TEST_NAME_IMPLICIT_DIGEST, false)));
Name decodedName2 = new Name();
try {
decodedName2.wireDecode(new Blob(TEST_NAME_IMPLICIT_DIGEST, false),
net.named_data.jndn.encoding.TlvWireFormat.get());
} catch (EncodingException ex_0) {
Assert.Fail("Can't decode TEST_NAME");
}
Assert.AssertEquals(decodedName2, name2);
}
示例7: addKey
/// <summary>
/// Add the key with keyName and keyBlob to the database.
/// </summary>
///
/// <param name="keyName">The key name.</param>
/// <param name="keyBlob">The encoded key.</param>
/// <exception cref="ConsumerDb.Error">if a key with the same keyName already exists inthe database, or other database error.</exception>
public override void addKey(Name keyName, Blob keyBlob)
{
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3ConsumerDbBase.INSERT_addKey);
statement.setBytes(1, keyName.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
statement.setBytes(2, keyBlob.getImmutableArray());
try {
statement.executeUpdate();
} finally {
statement.close();
}
} catch (SQLException exception) {
throw new ConsumerDb.Error(
"Sqlite3ConsumerDb.addKey: SQLite error: " + exception);
}
}
示例8: getKey
/// <summary>
/// Get the key with keyName from the database.
/// </summary>
///
/// <param name="keyName">The key name.</param>
/// <returns>A Blob with the encoded key, or an isNull Blob if cannot find the
/// key with keyName.</returns>
/// <exception cref="ConsumerDb.Error">for a database error.</exception>
public override Blob getKey(Name keyName)
{
try {
PreparedStatement statement = database_
.prepareStatement(net.named_data.jndn.encrypt.Sqlite3ConsumerDbBase.SELECT_getKey);
statement.setBytes(1, keyName.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get())
.getImmutableArray());
Blob key = new Blob();
try {
SqlDataReader result = statement.executeQuery();
if (result.NextResult())
key = new Blob(result.getBytes(1), false);
} finally {
statement.close();
}
return key;
} catch (SQLException exception) {
throw new ConsumerDb.Error(
"Sqlite3ConsumerDb.getKey: SQLite error: " + exception);
}
}