复合设计模式

问题描述:





我需要在内部维护需求的层次结构并在数组列表中存储名称并对其进行一些操作,所以我使用的是复合设计.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://*.com/questions/1913655/c-sharp-hierarchical-categories-structure [ ^ ]

http://*.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://*.com/questions/1913655/c-sharp-hierarchical-categories-structure[^]
http://*.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.