public static TreeNode GetNode(this TClass sourceBindObj) whrer TClass:ITreeNode<TClass>

{

 TreeNode node = new  TreeNode(){

  Text = TClass.Text,

Value = TClass.Value 

};

foreach(souceBindObj child in node.Children.orderby(item => item.Order))

{

  node.Children.add(GetNode(child));

retrun node; 

 

// 为了演示清楚创建的泛型接口,程序项目中不是这样的。 

 interface ITreeNode<T>

{

IEnumrable<T> Children{get;set;}

T Parent{get;set;}

string value{get;} // 提供Value

string Text{get;} // 提供Text 

int Order{get;} 

相关文章:

  • 2022-01-07
  • 2021-10-04
  • 2021-08-10
  • 2022-12-23
  • 2021-07-30
  • 2021-09-27
  • 2021-05-26
  • 2021-04-09
猜你喜欢
  • 2021-12-03
  • 2022-12-23
  • 2021-12-18
  • 2021-12-27
  • 2021-12-24
  • 2021-05-19
  • 2023-02-23
相关资源
相似解决方案