本文整理汇总了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);
}
示例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);
}
示例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}});
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}