using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ButcherManage.BO
|
|
{
|
|
public interface IWithNumber
|
|
{
|
|
int? Number { get; set; }
|
|
}
|
|
|
|
public class EntityExpand
|
|
{
|
|
public int? Number1 { get; set; }
|
|
|
|
public int? Number2 { get; set; }
|
|
|
|
public int? Number3 { get; set; }
|
|
|
|
public int? Number4 { get; set; }
|
|
|
|
public int? Number5 { get; set; }
|
|
|
|
public static List<EntityExpand> Build<T>(List<T> list)
|
|
where T : IWithNumber
|
|
{
|
|
var result = new List<EntityExpand>();
|
|
var t = typeof(EntityExpand);
|
|
for (var i = 0; i < list.Count; )
|
|
{
|
|
var entity = new EntityExpand();
|
|
result.Add(entity);
|
|
for (var j = 1; j <= 5; j++)
|
|
{
|
|
t.GetProperty(string.Format("Number{0}", j)).SetValue(entity, list[i].Number);
|
|
i++;
|
|
if (i == list.Count)
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|