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


C# IRepository.RetrieveSingleNode方法代码示例

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


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

示例1: Retrieve

		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// execute the query
			return repository.RetrieveSingleNode(context, query);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:16,代码来源:RetrieveNodeTag.cs

示例2: Retrieve

		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// make sure a child of clause is specified
			if (!query.HasSpecification<ChildOfSpecification>())
				throw new InvalidOperationException("The parent node was not specified.");

			// execute the query
			return repository.RetrieveSingleNode(context, query);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:20,代码来源:RetrieveChildNodeTag.cs

示例3: Retrieve

        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The request context.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the node
            var contentNode = GetRequiredAttribute<Node>(context, "source");

            //  get the page type
            var pageType = typeService.Load(context, "Page");

            // find the closest node pointer of type Page
            var pageNodePointer = contentNode.Pointer.HierarchyReverse.FirstOrDefault(x => typeService.Load(context, x.Type).IsAssignable(pageType));
            if (pageNodePointer == null)
                throw new InvalidOperationException(string.Format("Node '{0}' does not have a parent which is a Page", contentNode.Pointer.StructureString));

            // retrieve and return the parent node
            return repository.RetrieveSingleNode(context, new PropertyBag {{"id", pageNodePointer.Id}});
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:24,代码来源:RetrieveLayoutNodeTag.cs

示例4: Retrieve

        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The <see cref="IMansionContext"/>.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the url
            Url url;
            if (!arguments.TryGet(context, "url", out url))
                url = context.Cast<IMansionWebContext>().Request.RequestUrl;

            // parse the query
            var query = parser.Parse(context, new PropertyBag
                                              {
                                              	{"baseType", "Site"},
                                              	{"hostHeaders", url.HostName}
                                              });

            // execute the query
            return repository.RetrieveSingleNode(context, query);
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:25,代码来源:RetrieveSiteNodeTag.cs

示例5: Retrieve

		/// <summary>
		/// Builds and executes the query.
		/// </summary>
		/// <param name="context">The request context.</param>
		/// <param name="arguments">The arguments from which to build the query.</param>
		/// <param name="repository">The <see cref="IRepository"/>.</param>
		/// <param name="parser">The <see cref="IQueryParser"/>.</param>
		/// <returns>Returns the result.</returns>
		protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
		{
			// parse the query
			var query = parser.Parse(context, arguments);

			// make sure a child of clause is specified
			var parentOfSpecifications = query.Components.OfType<SpecificationQueryComponent>().Select(component => component.Specification).OfType<ParentOfSpecification>().ToArray();
			if (!parentOfSpecifications.Any())
				throw new InvalidOperationException("The child node was not specified.");

			// if there is a parent of specification for depth 0 it means a parent of the root node is queried, which does not exist
			if (parentOfSpecifications.Any(candidate => candidate.ChildPointer.Depth == 1))
				return null;

			// execute the query
			return repository.RetrieveSingleNode(context, query);
		}
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:25,代码来源:RetrieveParentNodeTag.cs

示例6: Retrieve

        /// <summary>
        /// Builds and executes the query.
        /// </summary>
        /// <param name="context">The <see cref="IMansionContext"/>.</param>
        /// <param name="arguments">The arguments from which to build the query.</param>
        /// <param name="repository">The <see cref="IRepository"/>.</param>
        /// <param name="parser">The <see cref="IQueryParser"/>.</param>
        /// <returns>Returns the result.</returns>
        protected override Record Retrieve(IMansionContext context, IPropertyBag arguments, IRepository repository, IQueryParser parser)
        {
            // get the url
            Url url;
            if (!arguments.TryGet(context, "url", out url))
                url = context.Cast<IMansionWebContext>().Request.RequestUrl;

            // parse the URL for identifiers
            IPropertyBag queryAttributes;
            if (!nodeUrlService.TryExtractQueryParameters(context.Cast<IMansionWebContext>(), url, out queryAttributes))
                return null;

            // parse the query
            var query = parser.Parse(context, queryAttributes);

            // execute the query
            return repository.RetrieveSingleNode(context, query);
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:26,代码来源:RetrieveNodeByUrlTag.cs

示例7: RetrieveRoleOwnerNode

        /// <summary>
        /// Retrieves the role owner node.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="owner"></param>
        /// <param name="repository"></param>
        /// <returns></returns>
        private static Node RetrieveRoleOwnerNode(IMansionContext context, RoleOwner owner, IRepository repository)
        {
            // if the user is not authenticated, retrieve the visiter from the database
            Node node;
            if (owner.Id == Guid.Empty)
            {
                node = repository.RetrieveSingleNode(context, new PropertyBag
                                                              {
                                                              	{"baseType", "RoleOwner"},
                                                              	{"key", "AnonymousUser"},
                                                              	{"bypassAuthorization", true},
                                                              	{StorageOnlyQueryComponent.PropertyKey, true}
                                                              });
                if (node == null)
                    throw new InvalidOperationException("Could not find the anonymous user node");
            }
            else
            {
                node = repository.RetrieveSingleNode(context, new PropertyBag
                                                              {
                                                              	{"baseType", "RoleOwner"},
                                                              	{"guid", owner.Id},
                                                              	{"bypassAuthorization", true},
                                                              	{StorageOnlyQueryComponent.PropertyKey, true}
                                                              });
                if (node == null)
                    throw new InvalidOperationException(string.Format("Could not find role owner with foreign ID {0} in repository, please sync tables", owner.Id));
            }

            return node;
        }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:38,代码来源:RepositorySecurityPersistenceService.cs

示例8: RetrieveRoleNode

 /// <summary>
 /// Retrieves the role node.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="role"></param>
 /// <param name="repository"></param>
 /// <returns></returns>
 private static Node RetrieveRoleNode(IMansionContext context, Role role, IRepository repository)
 {
     var node = repository.RetrieveSingleNode(context, new PropertyBag
                                                       {
                                                       	{"baseType", "Role"},
                                                       	{"guid", role.Id},
                                                       	{"bypassAuthorization", true},
                                                       	{StorageOnlyQueryComponent.PropertyKey, true}
                                                       });
     if (node == null)
         throw new InvalidOperationException(string.Format("Could not find role with ID {0} in repository, please sync tables", role.Id));
     return node;
 }
开发者ID:Erikvl87,项目名称:Premotion-Mansion,代码行数:20,代码来源:RepositorySecurityPersistenceService.cs


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