我目前正在使用大量硬編碼內存位置訪問一個硬件的項目。這些位置可以根據電氣工程師的心血來改變,所以我希望從工程師的存儲器映射中生成代碼。比方說,地圖是一個簡單的文本文件,如:類似有沒有簡單的方法從文本文件生成代碼?
Name, Type, Address, Description
Foo, int, A001, Foo integer variable
Bar, float, A002, Bar float variable
我想自動生成代碼(不是IL):
class MachineMap
{
/// <summary>
/// Foo integer variable
/// </summary>
public readonly Addressable<int> Foo = new Addressable<int>("A001");
/// <summary>
/// Bar float variable
/// </summary>
public readonly Addressable<float> Bar = new Addressable<float>("A002");
}
有沒有人對工具,將使這一任務的想法容易,還是更容易?
我不明白,爲什麼你需要比StreamWriter更多? – 2010-03-10 20:43:45
上面的例子很幼稚。我有許多不同類型的可尋址類,並希望構建一些層次結構; .e.g MachineMap.Arm1.Sensor1.Value等 – 2010-03-10 23:11:33