Show / Hide Table of Contents

Class PGN

Represents a http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htmPGN (portable game notation) file.

Inheritance
System.Object
PGN
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: PonzianiComponents.Chesslib
Assembly: PonzianiComponents.dll
Syntax
public class PGN

Constructors

| Improve this Doc View Source

PGN(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 Source

Filename

The PGN file's name

Declaration
public string Filename { get; }
Property Value
Type Description
System.String
| Improve this Doc View Source

GameCount

The number of games contained in the PGN File

Declaration
public int GameCount { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

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

| Improve this Doc View Source

Players

Declaration
public List<string> Players { get; }
Property Value
Type Description
System.Collections.Generic.List<System.String>

Methods

| Improve this Doc View Source

GetGame(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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX