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


C# Name.toEscapedString方法代碼示例

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


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

示例1: excludeRange

        /// <summary>
        /// Exclude all components in the range beginning at "from" and ending at "to".
        /// </summary>
        ///
        /// <param name="exclude">The Exclude object to update.</param>
        /// <param name="from">The first component in the exclude range.</param>
        /// <param name="to">The last component in the exclude range.</param>
        private static void excludeRange(Exclude exclude, Name.Component from,
				Name.Component to)
        {
            if (from.compare(to) >= 0) {
                if (from.compare(to) == 0)
                    throw new Exception(
                            "excludeRange: from == to. To exclude a single component, sue excludeOne.");
                else
                    throw new Exception(
                            "excludeRange: from must be less than to. Invalid range: ["
                                    + from.toEscapedString() + ", "
                                    + to.toEscapedString() + "]");
            }

            ArrayList entries = getExcludeEntries(exclude);

            int iNewFrom;
            int iFoundFrom = findEntryBeforeOrAt(entries, from);
            if (iFoundFrom < 0) {
                // There is no entry before "from" so insert at the beginning.
                entries.Insert(0, new Producer.ExcludeEntry (from, true));
                iNewFrom = 0;
            } else {
                Producer.ExcludeEntry  foundFrom = (Producer.ExcludeEntry ) entries[iFoundFrom];

                if (!foundFrom.anyFollowsComponent_) {
                    if (foundFrom.component_.equals(from)) {
                        // There is already an entry with "from", so just set the "ANY" flag.
                        foundFrom.anyFollowsComponent_ = true;
                        iNewFrom = iFoundFrom;
                    } else {
                        // Insert following the entry before "from".
                        entries.Insert(iFoundFrom + 1, new Producer.ExcludeEntry (from, true));
                        iNewFrom = iFoundFrom + 1;
                    }
                } else
                    // The entry before "from" already has an "ANY" flag, so do nothing.
                    iNewFrom = iFoundFrom;
            }

            // We have at least one "from" before "to", so we know this will find an entry.
            int iFoundTo = findEntryBeforeOrAt(entries, to);
            Producer.ExcludeEntry  foundTo = (Producer.ExcludeEntry ) entries[iFoundTo];
            if (iFoundTo == iNewFrom)
                // Insert the "to" immediately after the "from".
                entries.Insert(iNewFrom + 1, new Producer.ExcludeEntry (to, false));
            else {
                int iRemoveEnd;
                if (!foundTo.anyFollowsComponent_) {
                    if (foundTo.component_.equals(to))
                        // The "to" entry already exists. Remove up to it.
                        iRemoveEnd = iFoundTo;
                    else {
                        // Insert following the previous entry, which will be removed.
                        entries.Insert(iFoundTo + 1, new Producer.ExcludeEntry (to, false));
                        iRemoveEnd = iFoundTo + 1;
                    }
                } else
                    // "to" follows a component which is already followed by "ANY", meaning
                    // the new range now encompasses it, so remove the component.
                    iRemoveEnd = iFoundTo + 1;

                // Remove intermediate entries since they are inside the range.
                int iRemoveBegin = iNewFrom + 1;
                int nRemoveNeeded = iRemoveEnd - iRemoveBegin;
                for (int i = 0; i < nRemoveNeeded; ++i)
                    ILOG.J2CsMapping.Collections.Collections.RemoveAt(entries,iRemoveBegin);
            }

            setExcludeEntries(exclude, entries);
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:78,代碼來源:Producer.cs

示例2: testExcludeMatches

        public void testExcludeMatches()
        {
            Exclude exclude = new Exclude();
            exclude.appendComponent(new Name("%00%02").get(0));
            exclude.appendAny();
            exclude.appendComponent(new Name("%00%20").get(0));

            Name.Component component;
            component = new Name("%00%01").get(0);
            Assert.AssertFalse(component.toEscapedString() + " should not match "
                    + exclude.toUri(), exclude.matches(component));
            component = new Name("%00%0F").get(0);
            Assert.AssertTrue(
                    component.toEscapedString() + " should match "
                            + exclude.toUri(), exclude.matches(component));
            component = new Name("%00%21").get(0);
            Assert.AssertFalse(component.toEscapedString() + " should not match "
                    + exclude.toUri(), exclude.matches(component));
        }
開發者ID:named-data,項目名稱:ndn-dot-net,代碼行數:19,代碼來源:TestInterestMethods.cs


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