本文整理汇总了C#中ISecurityService.IsAuthorized方法的典型用法代码示例。如果您正苦于以下问题:C# ISecurityService.IsAuthorized方法的具体用法?C# ISecurityService.IsAuthorized怎么用?C# ISecurityService.IsAuthorized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISecurityService
的用法示例。
在下文中一共展示了ISecurityService.IsAuthorized方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders an action projection to given html output.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="securityService"></param>
/// <param name="html">The html helper.</param>
/// <returns><c>true</c> on success, otherwise <c>false</c>.</returns>
public override bool Render(IPage page, ISecurityService securityService, HtmlHelper html)
{
if (AccessRole != null && !securityService.IsAuthorized(AccessRole))
{
return false;
}
using (HtmlControlRenderer control = new HtmlControlRenderer(Tag))
{
OnPreRender(control, page, html);
using (HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.Writer))
{
control.RenderBeginTag(writer);
if (ChildProjections != null)
{
foreach (var htmlElementProjection in ChildProjections.OrderBy(f => f.Order))
{
htmlElementProjection.Render(page, securityService, html);
}
}
control.RenderEndTag(writer);
}
}
return true;
}
示例2: Render
/// <summary>
/// Renders a control.
/// </summary>
/// <param name="page">The page.</param>
/// <param name="securityService"></param>
/// <param name="html">The HTML.</param>
/// <returns><c>true</c> on success, otherwise <c>false</c>.</returns>
public virtual bool Render(IPage page, ISecurityService securityService, HtmlHelper html)
{
if (ShouldBeRendered != null && !ShouldBeRendered.Invoke(page))
{
return false;
}
if (AccessRole != null && !securityService.IsAuthorized(AccessRole))
{
return false;
}
using (HtmlControlRenderer control = new HtmlControlRenderer(Tag, isSelfClosing))
{
OnPreRender(control, page, html);
using (HtmlTextWriter writer = new HtmlTextWriter(html.ViewContext.Writer))
{
control.RenderControl(writer);
}
}
return true;
}