FX2下Web工作通过
Stone 编写于 2015-05-17 01:12:51
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 NewLife.Model;
using XCode;
using XCode.Membership;

/// <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 = CommonService.Get<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; } }
}