Exemplo n.º 1
0
 public override void Encode(string propertyName, SGF_Root_Setting setting)
 {
     encoded_ = new List <byte[]>();
     if (!Left.IsBlank)
     {
         Left.Encode(propertyName, setting);
     }
     if (!Right.IsBlank)
     {
         Right.Encode(propertyName, setting);
     }
     if (Left.Encoded.Count != 0 && Right.Encoded.Count != 0)
     {
         byte[] buffer = new byte[Left.Encoded[0].Length + Right.Encoded[0].Length + 1];
         Buffer.BlockCopy(Left.Encoded[0], 0, buffer, 0, Left.Encoded[0].Length);
         buffer[Left.Encoded[0].Length] = (byte)':';
         Buffer.BlockCopy(Right.Encoded[0], 0, buffer, Left.Encoded[0].Length + 1, Right.Encoded[0].Length);
         encoded_.Add(buffer);
     }
     else if (Left.Encoded.Count != 0)
     {
         encoded_.Add(Left.Encoded[0]);
     }
     else if (Right.Encoded.Count != 0)
     {
         byte[] buffer = new byte[Right.Encoded[0].Length + 1];
         buffer[0] = (byte)':';
         Buffer.BlockCopy(Right.Encoded[0], 0, buffer, 1, Right.Encoded[0].Length);
         encoded_.Add(buffer);
     }
 }
Exemplo n.º 2
0
        public override void Encode(string propertyName, SGF_Root_Setting setting)
        {
            List <byte[]> result = new List <byte[]>();

            result.Add(Encoding.ASCII.GetBytes(value_.ToString()));
            encoded_ = result;
        }
Exemplo n.º 3
0
 public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
     LogSingleValueVerification(values, propertyName, setting);
     if (values.Count == 1)
     {
         List <byte[]> oneValue = Util.SplitByteArrayBy(values[0], ':');
         if (oneValue.Count > 0)
         {
             // Left
             leftValue_ = new T();
             List <byte[]> leftvalues = new List <byte[]>();
             leftvalues.Add(oneValue[0]);
             leftValue_.Decode(leftvalues, propertyName, setting);
             isBlank_ = false;
         }
         if (oneValue.Count > 1)
         {
             // Right
             rightValue_ = new U();
             List <byte[]> rightvalues = new List <byte[]>();
             rightvalues.Add(oneValue[1]);
             rightValue_.Decode(rightvalues, propertyName, setting);
         }
     }
 }
Exemplo n.º 4
0
 public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
     LogSingleValueVerification(values, propertyName, setting);
     if (values.Count == 1)
     {
         text_ = Util.Escaping(Encoding.ASCII.GetString(values[0]));
     }
 }
Exemplo n.º 5
0
        public override void Encode(string propertyName, SGF_Root_Setting setting)
        {
            List <byte[]> result = new List <byte[]>();

            result.Add(new byte[2] {
                Util.IntToMove(x_), Util.IntToMove(y_)
            });
            encoded_ = result;
        }
Exemplo n.º 6
0
 public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
     LogSingleValueVerification(values, propertyName, setting);
     if (values.Count == 1)
     {
         value_   = int.Parse(Encoding.ASCII.GetString(values[0]));
         isBlank_ = false;
     }
 }
Exemplo n.º 7
0
 public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
     LogSingleValueVerification(values, propertyName, setting);
     if (values.Count == 1)
     {
         if (values[0].Length != 2)
         {
             setting.PushError(propertyName, "The point type has the incorrect format");
             return;
         }
         x_ = Util.MoveToInt(values[0][0]);
         y_ = Util.MoveToInt(values[0][1]);
         if (x_ != -1 || y_ != -1)
         {
             isBlank_ = false;
         }
         else
         {
             setting.PushError(propertyName, "The point type has the incorrect format");
         }
     }
 }
Exemplo n.º 8
0
 public override void Encode(string propertyName, SGF_Root_Setting setting)
 {
 }
Exemplo n.º 9
0
 public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
 }
Exemplo n.º 10
0
 public abstract void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting);
Exemplo n.º 11
0
 public abstract void Encode(string propertyName, SGF_Root_Setting setting);
Exemplo n.º 12
0
 protected void LogSingleValueVerification(List <byte[]> values, string propertyName, SGF_Root_Setting setting)
 {
     if (values.Count > 1)
     {
         setting.PushError(propertyName, "The property has multi values");
     }
 }
Exemplo n.º 13
0
 internal override List <byte[]> ToPropertyValues(SGF_Root_Setting setting)
 {
     value_.Encode(name_, setting);
     return(value_.Encoded);
 }
Exemplo n.º 14
0
 protected override void OnSetValue(List <byte[]> values, SGF_Root_Setting setting)
 {
     value_.Decode(values, name_, setting);
 }
Exemplo n.º 15
0
 internal abstract List <byte[]> ToPropertyValues(SGF_Root_Setting setting);
Exemplo n.º 16
0
 protected abstract void OnSetValue(List <byte[]> values, SGF_Root_Setting setting);