예제 #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);
 }