Convert text file to dictionary or anonymous type object
- by Robert Harvey
I have a text file that looks like this:
adapter 1: LPe11002
Factory IEEE: 10000000 C97A83FC
Non-Volatile WWPN: 10000000 C93D6A8A , WWNN: 20000000 C93D6A8A
adapter 2: LPe11002
Factory IEEE: 10000000 C97A83FD
Non-Volatile WWPN: 10000000 C93D6A8B , WWNN: 20000000 C93D6A8B
Is there a way to get this information into an anonymous type or dictionary object?
The final anonymous type might look something like this, if it were composed in C# by hand:
new
{
adapter1 = new
{
FactoryIEEE = "10000000 C97A83FC",
Non-VolatileWWPN = "10000000 C93D6A8A",
WWNN = "20000000 C93D6A8A"
}
adapter2 = new
{
FactoryIEEE = "10000000 C97A83FD",
Non-VolatileWWPN = "10000000 C93D6A8B",
WWNN = "20000000 C93D6A8B"
}
}