用户自定义控件基类不需要检查权限,只有页面基类需要
Stone 编写于 2012-06-11 00:56:55
X
/*
 * XCoder v4.4.2011.1031
 * 作者:nnhy/NEWLIFE
 * 时间:2011-11-07 16:54:58
 * 版权:版权所有 (C) 新生命开发团队 2011
*/
using System;
using System.Web.UI;
using NewLife.CommonEntity;
using XCode;

/// <summary>实体用户控件基类</summary>
public class MyEntityUserControl : UserControl
{
    #region 管理页控制器
    private Type _EntityType;
    /// <summary>实体类</summary>
    public virtual Type EntityType { get { return _EntityType; } set { _EntityType = value; } }

    /// <summary>表单控制器</summary>
    protected IEntityForm EntityForm;

    protected override void OnInit(EventArgs e)
    {
        EntityForm = ManageProvider.Provider.GetService<IEntityForm>().Init(this, EntityType);

        base.OnInit(e);
    }
    #endregion
}

/// <summary>实体用户控件基类</summary>
public class MyEntityUserControl<TEntity> : MyEntityUserControl where TEntity : Entity<TEntity>, new()
{
    /// <summary>实体类</summary>
    public override Type EntityType { get { return base.EntityType ?? (base.EntityType = typeof(TEntity)); } set { base.EntityType = value; } }

    /// <summary>实体</summary>
    public virtual TEntity Entity { get { return EntityForm == null ? null : EntityForm.Entity as TEntity; } set { if (EntityForm != null) EntityForm.Entity = value; } }
}