当前位置: 首页>>代码示例>>C#>>正文


C# Interest.matchesName方法代码示例

本文整理汇总了C#中net.named_data.jndn.Interest.matchesName方法的典型用法代码示例。如果您正苦于以下问题:C# Interest.matchesName方法的具体用法?C# Interest.matchesName怎么用?C# Interest.matchesName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.named_data.jndn.Interest的用法示例。


在下文中一共展示了Interest.matchesName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: onInterest

        public void onInterest(Name prefix, Interest interest, Face face,
				long interestFilterId, InterestFilter filter)
        {
            doCleanup();

            Name.Component selectedComponent = null;
            Blob selectedEncoding = null;
            // We need to iterate over both arrays.
            int totalSize = staleTimeCache_.Count + noStaleTimeCache_.Count;
            for (int i = 0; i < totalSize; ++i) {
                MemoryContentCache.Content  content;
                if (i < staleTimeCache_.Count)
                    content = staleTimeCache_[i];
                else
                    // We have iterated over the first array. Get from the second.
                    content = noStaleTimeCache_[i - staleTimeCache_.Count];

                if (interest.matchesName(content.getName())) {
                    if (interest.getChildSelector() < 0) {
                        // No child selector, so send the first match that we have found.
                        try {
                            face.send(content.getDataEncoding());
                        } catch (IOException ex) {
                            ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName)
                                    .log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex);
                        }
                        return;
                    } else {
                        // Update selectedEncoding based on the child selector.
                        Name.Component component;
                        if (content.getName().size() > interest.getName().size())
                            component = content.getName().get(
                                    interest.getName().size());
                        else
                            component = emptyComponent_;

                        bool gotBetterMatch = false;
                        if (selectedEncoding == null)
                            // Save the first match.
                            gotBetterMatch = true;
                        else {
                            if (interest.getChildSelector() == 0) {
                                // Leftmost child.
                                if (component.compare(selectedComponent) < 0)
                                    gotBetterMatch = true;
                            } else {
                                // Rightmost child.
                                if (component.compare(selectedComponent) > 0)
                                    gotBetterMatch = true;
                            }
                        }

                        if (gotBetterMatch) {
                            selectedComponent = component;
                            selectedEncoding = content.getDataEncoding();
                        }
                    }
                }
            }

            if (selectedEncoding != null) {
                // We found the leftmost or rightmost child.
                try {
                    face.send(selectedEncoding);
                } catch (IOException ex_0) {
                    ILOG.J2CsMapping.Util.Logging.Logger.getLogger(typeof(MemoryContentCache).FullName).log(
                            ILOG.J2CsMapping.Util.Logging.Level.SEVERE, null, ex_0);
                }
            } else {
                // Call the onDataNotFound callback (if defined).
                Object onDataNotFound = ILOG.J2CsMapping.Collections.Collections.Get(onDataNotFoundForPrefix_,prefix.toUri());
                if (onDataNotFound != null) {
                    try {
                        ((OnInterestCallback) onDataNotFound).onInterest(prefix,
                                interest, face, interestFilterId, filter);
                    } catch (Exception ex_1) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onDataNotFound", ex_1);
                    }
                }
            }
        }
开发者ID:named-data,项目名称:ndn-dot-net,代码行数:81,代码来源:MemoryContentCache.cs


注:本文中的net.named_data.jndn.Interest.matchesName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。