You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Supports all data types (incl compressed point lists)
Out of the box implementations for all properties needed for Go (GM[1])
SGF v4 parsing and generation
Parsing example
usingdnsl48.SGF.Model;usingdnsl48.SGF.Model.Property;// Parser state keeps all errorsvarparser=newdnsl48.SGF.NaiveParser();try{// The SGF tree collectiondnsl48.SGF.Model.Collectioncollection=parser.Parse(sgfBlob);catch(dnsl48.SGF.NaiveParser.IParseErrore){// incorrect SGF document}catch(Exceptione){// unexpected runtime exception}// Strictly typed model for working with the tree// It's all have already been validated when parsedtry{varnode=collection.trees[0].nodes[0];// SZ[19] becomes Model.Property.Root.BoardSizeif(node.props.has("SZ")){Root.BoardSizesize=(Root.BoardSize)node.props["SZ"];size.x==19;size.y==19;}// RE[W+3.5] becomes Model.Property.Info.GameResultif(node.props.ContainsKey("RE")){Info.GameResultresult=(Info.GameResult)node.props["RE"];if(result.how==GameResult.WinType.Score){result.who==Colour.White;// White wonresult.score==3.5m;// how much}}}
Generation example
usingdnsl48.SGF.Model;usingdnsl48.SGF.Types;// Use Model to generate SGFvarcollection=newCollection(newTree[]{// the sequence of collection treesnewTree(newNode[]{// the sequence of tree nodesnewNode(newIProperty[]{// the sequence of node properties// Application becomes "AP"(IProperty)newApplication(newSimpleComposedText("Sharp SGF tools"),newSimpleComposedText("0.0.1")),// GameResult becomes "RE"(IProperty)newGameResult(Colour.Black,8.5m),// GameType becomes "GM"(IProperty)newGameType(1)})},newTree[]{}// the child trees go here)});stringsgfBlob=collection.ToString();// sgfBlob contains the following: "(;AP[Sharp SGF tools:0.0.1] RE[B+8.5] GM[1])"