Class PGN
Represents a http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htmPGN (portable game notation) file.
Inheritance
Inherited Members
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class PGN
  Constructors
| Improve this Doc View SourcePGN(String)
Creates a new PGN object for File filename
Declaration
public PGN(string filename)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filename | The PGN file's name  | 
      
Properties
| Improve this Doc View SourceFilename
The PGN file's name
Declaration
public string Filename { get; }
  Property Value
| Type | Description | 
|---|---|
| System.String | 
GameCount
The number of games contained in the PGN File
Declaration
public int GameCount { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
Games
The parsed games contained in the PGN File
Declaration
public List<Game> Games { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<Game> | 
Remarks
The List is only filled after LoadAsync(Boolean) has been executed
Players
Declaration
public List<string> Players { get; }
  Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.String> | 
Methods
| Improve this Doc View SourceGetGame(Int32)
Reads and parses the game with index index from the PGN-File
Declaration
public Game GetGame(int index)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | index | the index of the game to be read  | 
      
Returns
| Type | Description | 
|---|---|
| Game | The parsed Game  | 
      
GetGames(Boolean)
Returns an Enumerable which returns one parsed Game after the other while reading the input PGN file
Declaration
public IEnumerable<Game> GetGames(bool comments = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | comments | if true, comments are parsed as well  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<Game> | Enumerable with parsed Games  | 
      
LoadAsync(Boolean)
Loads the file's content into memory and parses it
Declaration
public async Task<int> LoadAsync(bool comments = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | comments | 
Returns
| Type | Description | 
|---|---|
| System.Threading.Tasks.Task<System.Int32> | The number of games  | 
      
Parse(String, Boolean, Boolean, Int32, Int32)
Parses a pgn-file into a List of Games
Declaration
public static List<Game> Parse(string pgn, bool comments = false, bool variations = false, int count = 2147483647, int offset = 0)
  Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | pgn | The PGN input  | 
      
| System.Boolean | comments | if true, comments are parsed as well  | 
      
| System.Boolean | variations | if true, variations are parsed as well  | 
      
| System.Int32 | count | Number of games to be parsed (default: all)  | 
      
| System.Int32 | offset | Index of first game to be parsed  | 
      
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<Game> | List of parsed Games  | 
      
ResultToString(Result)
Converts the Result to a string as used f.e. in PGN Format. It will return one of "*", "1-0", "0-1", "1/2-1/2"
Declaration
public static string ResultToString(Result result)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Result | result | The result to be converted  | 
      
Returns
| Type | Description | 
|---|---|
| System.String | The result as string  |