public interface ITubeBox
{
void Clear();
void IntData();
List<uc_TubeBox_Data> ls { get; set; }
}
public class TubeBoxFactory
{
private static ITubeBox _helper = null;
/// <summary>
///
/// </summary>
/// <returns></returns>
public static ITubeBox Create()
{
return _helper;
}
/// <summary>
///
/// </summary>
/// <param name="helper"></param>
public static void SetContainerHelper(ITubeBox helper)
{
_helper = helper;
}
public static void AddControl(Grid grd)
{
grd.Children.Clear();
switch (Global.TubeBoxType)
{
case "96": _helper = new uc_TubeBox(); break;
case "48": _helper = new uc_TubeBox_48(); break;
default: _helper = new uc_TubeBox_48(); break;//默认96
}
grd.Children.Add(_helper as UserControl);
}
public partial class uc_TubeBox : UserControl, ITubeBox
{
List<string> ITubeBox.lscheck
{
get => lscheck;
set
{
lscheck = value;
}
}
}
public partial class uc_TubeBox_48 : UserControl, ITubeBox
{}
//调用
TubeBoxFactory.AddControl(grd_tube);
TubeBoxFactory.Create().Dic_dataSouce_number
C# interface使用方法
最新推荐文章于 2023-03-27 22:52:18 发布