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


C# Name.wireEncode方法代碼示例

本文整理匯總了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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:39,代碼來源:Sqlite3GroupManagerDb.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:32,代碼來源:Sqlite3GroupManagerDb.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:32,代碼來源:Sqlite3GroupManagerDb.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:32,代碼來源:Sqlite3GroupManagerDb.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:26,代碼來源:Sqlite3GroupManagerDb.cs

示例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);
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:33,代碼來源:TestNameMethods.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:26,代碼來源:Sqlite3ConsumerDb.cs

示例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);
            }
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:32,代碼來源:Sqlite3ConsumerDb.cs


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