コード例 #1
0
        public override string ToString()
        {
            StringBuilder lStringBuilder = new StringBuilder();

            lStringBuilder.Append(";");

            SGFProperty lLastSGFProperty = null;

            foreach (SGFProperty lSGFProperty in Properties)
            {
                if (lLastSGFProperty == null)
                {
                    lStringBuilder.Append(lSGFProperty.ToString());
                }
                else
                if (lLastSGFProperty.PropertyID == lSGFProperty.PropertyID)
                {
                    lStringBuilder.Append(lSGFProperty.ToStringNoPropertyID());
                }
                else
                {
                    lStringBuilder.AppendLine();
                    lStringBuilder.Append(lSGFProperty.ToString());
                }

                lLastSGFProperty = lSGFProperty;
            }

            lStringBuilder.AppendLine();

            return(lStringBuilder.ToString());
        }
コード例 #2
0
 public void AddPropertyIfNotEmpty(SGFProperty sgfProperty)
 {
     if (!string.IsNullOrEmpty(sgfProperty.Text))
     {
         AddProperty(sgfProperty);
     }
 }
コード例 #3
0
ファイル: SGFNode.cs プロジェクト: tgiphil/GoTraxx
        public bool Read(MemFile memFile)
        {
            char c = memFile.Get();

            if (c != ';')
                return SetErrorMessage("Expecting semi-colon, found: " + c.ToString());

            while (true)
            {
                if (memFile.EOF)
                    return true;

                c = memFile.Peek();

                if (c == '(')
                    break;	// variation

                if ((c == ';') || (c == ')'))
                    break;

                if (Char.IsLetter(c))
                {
                    SGFProperty lSGFProperty = new SGFProperty(memFile);

                    if (lSGFProperty.IsError())
                        return SetErrorMessage(lSGFProperty);

                    AddProperty(lSGFProperty);

                    while (true)
                    {
                        c = memFile.Peek();

                        if (c == ')')
                            break;

                        if (c == '(')
                            break;

                        if (c == '[')
                        {
                            memFile.Get(); // eat this character

                            SGFProperty lSGFProperty2 = new SGFProperty(memFile, lSGFProperty.PropertyID);

                            if (lSGFProperty2.IsError())
                                return SetErrorMessage(lSGFProperty2); ;

                            AddProperty(lSGFProperty2);
                        }
                        else
                            if (!Char.IsLetter(c))
                            {
                                memFile.Get();	// eat this character

                                if (memFile.EOF)
                                    return SetErrorMessage("Unexpected EOF.");
                            }
                            else
                                break;

                    }
                }
                else
                    memFile.Get();	// eat this character

                if (memFile.EOF)
                    return SetErrorMessage("Unexpected EOF.");

            }

            return true;
        }
コード例 #4
0
ファイル: SGFNode.cs プロジェクト: tgiphil/GoTraxx
 public void AddPropertyIfNotEmpty(SGFProperty sgfProperty)
 {
     if (!string.IsNullOrEmpty(sgfProperty.Text))
         AddProperty(sgfProperty);
 }
コード例 #5
0
ファイル: SGFNode.cs プロジェクト: tgiphil/GoTraxx
 public void AddProperty(SGFProperty sgfProperty)
 {
     Properties.Add(sgfProperty);
 }
コード例 #6
0
        public bool Read(MemFile memFile)
        {
            char c = memFile.Get();

            if (c != ';')
            {
                return(SetErrorMessage("Expecting semi-colon, found: " + c.ToString()));
            }

            while (true)
            {
                if (memFile.EOF)
                {
                    return(true);
                }

                c = memFile.Peek();

                if (c == '(')
                {
                    break;                      // variation
                }
                if ((c == ';') || (c == ')'))
                {
                    break;
                }

                if (Char.IsLetter(c))
                {
                    SGFProperty lSGFProperty = new SGFProperty(memFile);

                    if (lSGFProperty.IsError())
                    {
                        return(SetErrorMessage(lSGFProperty));
                    }

                    AddProperty(lSGFProperty);

                    while (true)
                    {
                        c = memFile.Peek();

                        if (c == ')')
                        {
                            break;
                        }

                        if (c == '(')
                        {
                            break;
                        }

                        if (c == '[')
                        {
                            memFile.Get();                             // eat this character

                            SGFProperty lSGFProperty2 = new SGFProperty(memFile, lSGFProperty.PropertyID);

                            if (lSGFProperty2.IsError())
                            {
                                return(SetErrorMessage(lSGFProperty2));
                            }
                            ;

                            AddProperty(lSGFProperty2);
                        }
                        else
                        if (!Char.IsLetter(c))
                        {
                            memFile.Get();                                      // eat this character

                            if (memFile.EOF)
                            {
                                return(SetErrorMessage("Unexpected EOF."));
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    memFile.Get();                      // eat this character
                }
                if (memFile.EOF)
                {
                    return(SetErrorMessage("Unexpected EOF."));
                }
            }

            return(true);
        }
コード例 #7
0
 public void AddProperty(SGFProperty sgfProperty)
 {
     Properties.Add(sgfProperty);
 }