zoukankan      html  css  js  c++  java
  • Kooboo CMS

    DataContract

    数据契约

    http://www.cnblogs.com/Gavinzhao/archive/2010/06/01/1748736.html

    https://msdn.microsoft.com/zh-cn/library/system.runtime.serialization.datacontractattribute.aspx

    Html.FrontHtml.Position("main") 详解

    1.首先我们打开工程文件,在搜索框里写上FrontHtml查找到FrontHtmlHelper类,如下图:

    下面是关于Position的相关方法。

            #region Position
            public virtual IHtmlString Position(string positionID)
            {
                return Position(positionID, "");
            }
    
            public virtual IHtmlString Position(string positionID, string defaultContent)
            {
                return Position(positionID, () => defaultContent);
            }
            public virtual IHtmlString Position(string positionID, Func<string> defaultContentFunc)
            {
                if (PageContext.PageRequestContext.RequestChannel == FrontRequestChannel.Design)
                {
                    return new PageDesignHolder(this, positionID);
                }
                else
                {
                    var positions = GetContentsForPosition(positionID);
                    if (positions.Length == 0)
                    {
                        defaultContentFunc = defaultContentFunc == null ? () => "" : defaultContentFunc;
                        return new HtmlString(defaultContentFunc());
                    }
                    else
                    {
                        var htmlStrings = RenderPositionContents(positions).ToArray();
                        return new AggregateHtmlString(htmlStrings);
                    }
    
                }
            }
    
            public virtual IHtmlString Position(string positionID, bool requireMembershipAuthentication, params string[] membershipGroups)
            {
                if (PageContext.PageRequestContext.RequestChannel == FrontRequestChannel.Design)
                {
                    return new PageDesignHolder(this, positionID);
                }
                else
                {
                    if (requireMembershipAuthentication)
                    {
                        var permission = new PagePermission() { RequireMember = requireMembershipAuthentication, AllowGroups = membershipGroups };
                        if (!permission.Authorize(Html.ViewContext.HttpContext.Membership().GetMember()))
                        {
                            return new HtmlString("");
                        }
                    }
                    return Position(positionID);
                }
            }
    View Code

    下面来详细解释下。

    一共有4个重载函数分别是:

    public virtual IHtmlString Position(string positionID)

    public virtual IHtmlString Position(string positionID, string defaultContent)

    public virtual IHtmlString Position(string positionID, Func<string> defaultContentFunc)

    public virtual IHtmlString Position(string positionID, bool requireMembershipAuthentication, params string[] membershipGroups)

    这里如果有不明白的话可以,可以参考一下以下的知识:

    1.positionID的意思就是你的HTML元素的ID。

    2.如果对() => defaultContent)不理解的人,可以参看这里

    3.对于Func<string>不理解的可以看这里

  • 相关阅读:
    curl命令查看响应时间
    sshd修改监听端口
    nginx proxy_set_header设置,自定义header
    nginx.conf详解
    系统盘脚本扩容
    IDEA中编写脚本并运行shell脚本
    常用的pdf工具
    POJ:3279-Fliptile【状态压缩】【DFS】
    POJ:Dungeon Master(BFS模板题)
    #1198:Farm Irrigation(DFS + 并查集)
  • 原文地址:https://www.cnblogs.com/kmsfan/p/Kooboo-CMS_Html-FrontHtml-Position.html
Copyright © 2011-2022 走看看