iigorr / pgn.net

Portable Game Notation (PGN) implementation in .NET
Other
33 stars 24 forks source link

Accessing Header Fields #13

Closed iigorr closed 9 years ago

iigorr commented 9 years ago

@Dodgero wrote:

I don't know if what I am going to point out can be called that way, but I have noticed the library does not support some of the pgn header fields. I think it would be great if it would be possible to access them via properties and to get on the output the same what was on the input, so that no fields would be lost in the process. In other words, after operation pgn->reader->writer->pgn, the pgn should be the same on both sides. To make this happen, all headers would have to be processed, now they are cut off. Namely, header fields "WhiteElo", "BlackElo" I find as quite important.

Would you kindly consider adding support for other pgn header fields ? ;)

iigorr commented 9 years ago

As there are quite many fields (tags) and also people and chess platforms do introduce custom fields, only the fields defined by the spec as the STR (Seven Tag Roster) are available as properties in the Game class. All the other ones are stored in Game.AdditionalInfo as GameInfo objects, so no information should be lost and pgn->reader->writer->pgn should yield the same result (except for formatting).

I do agree, that WhiteElo and BlackElo are also very frequently used tags. And now looking at the interface of the Game class I find it quite awkward to access the fields as they are in a list. How about we change that List<GameInfo> AdditionalInfo to Dictionary<string, string> Tags so it can be accessed as game.Tags['WhiteElo']. What do you think?

iigorr commented 9 years ago

@Dodgero: I have implemented the Tags attribute as a dictonary. Version 1.2.0 is available as nuget package https://www.nuget.org/packages/pgn.NET/1.2.0.

Dodgero commented 9 years ago

This is great! I had no time to comment on this, sorry. I think it is a good decision. I will give it a try!

Cheers, Dodgero

2015-06-13 13:43 GMT+02:00 Igor Lankin notifications@github.com:

@Dodgero https://github.com/Dodgero: I have implemented the Tags attribute as a dictonary. Version 1.2.0 is available as nuget package https://www.nuget.org/packages/pgn.NET/1.2.0.

— Reply to this email directly or view it on GitHub https://github.com/iigorr/pgn.net/issues/13#issuecomment-111701750.