2012-03-29 76 views
0

目前,我解析一些非结构化的文本,并将其转换这样:存储和逻辑,容易呈现数据使用的方式

Type1 
Type1 Description1 - Type1 Specification1 
Type1 Description2 - Type1 Specification2 
Type1 Description3 - Type1 Specification3 
..more descriptions and specifications 

Type2 
Type2 Description1 - Type2 Specification1 
Type2 Description2 - Type2 Specification2 
Type2 Description3 - Type2 Specification3 
..more descriptions and specifications 

..more Types 

它是一个字符串 - 空间返回分隔符。 虽然很容易阅读,但我明白这不是有效的方法。这也是相当困难的拆卸它恢复到初始值组件(类型,描述,规格)

我的问题:

A.什么是在内存中存储这些数据的最有效方法,并与保存到磁盘(不在数据库中)的可能性?

I was thinking about XML, but I never worked with it 
and hardly understand it's structure; but if you think 
that is the only right way to do it, I guess I would 
have to work on it! 

B.什么会呈现在winform这个数据的最佳方式,考虑到有可能是多种类型和多种类型定义?

Here, I am not sure. I can continue using textbox, 
but it also does not seems to be the great way. 
Maybe generate HTML and then plug it in? Seems inefficient. 

回答

1

A)创建一个包含描述和规范的类;不知道应该叫什么。

创建具有上述类的列表的您自己的类型类。 (尽管不要将它称为Type,但它会与System.Type混淆。)

至于将它存储在磁盘上,XML不是一个坏主意,但它很简单,您可以将每个用逗号(或制表符)分隔的描述/规范对列表在文件中键入一行。 XML更容易以纯文本形式阅读,但更多的工作可供计算机处理,并且会在磁盘上使用更多空间。如果存在少量数据,我会使用XML,如果存在大量数据并且很少需要查看文件,我会考虑其他选项。

B)我会使用TreeView。