2012-03-29 78 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。