复合设计模式 [英] Composite Design Pattern

查看:95
本文介绍了复合设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要在内部维护需求的层次结构并在数组列表中存储名称并对其进行一些操作,所以我使用的是复合设计.Net的模式,但我仍然面临一些问题。

那么请你建议我如何解决这个问题?



层次结构应如下所示..



Hi,

I need to maintain the hierarchy of requirement internally and store names in array list and do some operations on it, so I’m using Composite design pattern of .Net, but still I am facing some problem on it.
So could you please suggest me how to resolve this problem?

Hierarchy should look like this..

1.  Requirement1
1.1.    Table1
1.1.1.  Column1
1.1.2.  Column2
1.1.3.  Column3
1.2.    Table2
1.2.1.  Column1
1.2.2.  Column2
1.2.3.  Column3
And so on…
2.  Reuirement2
2.1.    Table1
2.1.1.  Column1
2.1.2.  Column2
2.1.3.  Column3
2.2.    Table2
2.2.1.  Column1
2.2.2.  Column2
2.2.3.  Column3
And so on

推荐答案

您需要以分层方式存储数据,因此您不需要需要heirarichal数据结构的设计模式。我建议为这个工作创建和模仿树数据结构。你会在这里找到一些帮助:



http://stackoverflow.com/questions/1913655/c-sharp-hierarchical-categories-structure [ ^ ]

http://stackoverflow.com/questions/66893/tree-data-structure-in-c-sharp [ ^ ]



另外,你可以在网上找到很多关于如何使用C#创建树结构的好文章。
You need to store the data in hierarchical fashion so you don''t need a design pattern you need a heirarichal data structure. I suggest to create and mimic a tree data structure for this job. You will find some help on how to do this here:

http://stackoverflow.com/questions/1913655/c-sharp-hierarchical-categories-structure[^]
http://stackoverflow.com/questions/66893/tree-data-structure-in-c-sharp[^]

Also, you can find a lot of good article on how to create a tree structure using C# on the web.


这篇关于复合设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆