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


C# Term.Select方法代码示例

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


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

示例1: FilterNavigationNodesToRestrictedTermSet

        private IEnumerable<NavigationNode> FilterNavigationNodesToRestrictedTermSet(SPWeb web, Guid restrictedTermSetId, IEnumerable<NavigationNode> nodes, Term[] restrictedTerms = null)
        {
            // If first pass, initialize the restricted nodes with first level terms
            if (restrictedTerms == null)
            {
                // Get restricted term set
                var session = new TaxonomySession(web.Site);
                var termStore = session.DefaultSiteCollectionTermStore;
                var termSet = termStore.GetTermSet(restrictedTermSetId);
                restrictedTerms = termSet.Terms.ToArray();
            }

            // Flattened navigation nodes for easier search
            var flattenedNodes = nodes.Flatten(node => node.ChildNodes);
            var restrictedNodes = restrictedTerms.Select(term => flattenedNodes.SingleOrDefault(node => node.Id.Equals(term.Id))).ToArray();
            for (var i = 0; i < restrictedTerms.Length; i++)
            {
                var restrictedTerm = restrictedTerms[i];
                var restrictedNode = restrictedNodes[i];

                // If term contains children, recurvise call
                if (restrictedTerm.Terms.Count > 0)
                {
                    restrictedNode.ChildNodes = this.FilterNavigationNodesToRestrictedTermSet(web, restrictedTermSetId, nodes, restrictedTerm.Terms.ToArray());
                }
            }

            return restrictedNodes;
        }
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:29,代码来源:NavigationService.cs

示例2: FilterNavigationNodesToRestrictedTermSet

        private IEnumerable<NavigationNode> FilterNavigationNodesToRestrictedTermSet(SPWeb web, NavigationQueryParameters queryParameters, IEnumerable<NavigationNode> nodes, Term[] restrictedTerms = null)
        {
            // If first pass, initialize the restricted nodes with first level terms
            if (restrictedTerms == null)
            {
                // Get restricted term set
                var session = new TaxonomySession(web.Site);
                TermStore termStore = null;

                if (queryParameters.TermStoreId == Guid.Empty)
                {
                    termStore = this.taxonomyHelper.GetDefaultSiteCollectionTermStore(session);
                }
                else
                {
                    termStore = session.TermStores[queryParameters.TermStoreId];
                }

                var termSet = termStore.GetTermSet(queryParameters.RestrictedTermSetId);

                var nodeMatchingSettings = queryParameters.NodeMatchingSettings;
                if ((nodeMatchingSettings != null) && nodeMatchingSettings.RestrictToCurrentNavigationLevel)
                {
                    var currentTermId = TaxonomyNavigationContext.Current.NavigationTerm.Id;
                    restrictedTerms = termSet.GetTerm(currentTermId).Parent.Terms.ToArray();
                }
                else
                {
                    restrictedTerms = termSet.Terms.ToArray();
                }
            }

            // Flattened navigation nodes for easier search
            var flattenedNodes = nodes.Flatten(node => node.ChildNodes);
            var restrictedNodes = restrictedTerms.Select(term => flattenedNodes.SingleOrDefault(node => node.Id.Equals(term.Id))).ToArray();
            for (var i = 0; i < restrictedTerms.Length; i++)
            {
                var restrictedTerm = restrictedTerms[i];
                var restrictedNode = restrictedNodes[i];

                // If term contains children, recurvise call
                if (restrictedTerm.Terms.Count > 0)
                {
                    restrictedNode.ChildNodes = this.FilterNavigationNodesToRestrictedTermSet(web, queryParameters, nodes, restrictedTerm.Terms.ToArray());
                }
                else
                {
                    restrictedNode.ChildNodes = new List<NavigationNode>();
                }
            }

            return restrictedNodes;
        }
开发者ID:andresglx,项目名称:Dynamite,代码行数:53,代码来源:NavigationService.cs


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