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); } }
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; }
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); } } }
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])); } }
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; }
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; } }
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"); } } }
public override void Encode(string propertyName, SGF_Root_Setting setting) { }
public override void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting) { }
public abstract void Decode(List <byte[]> values, string propertyName, SGF_Root_Setting setting);
public abstract void Encode(string propertyName, SGF_Root_Setting setting);
protected void LogSingleValueVerification(List <byte[]> values, string propertyName, SGF_Root_Setting setting) { if (values.Count > 1) { setting.PushError(propertyName, "The property has multi values"); } }
internal override List <byte[]> ToPropertyValues(SGF_Root_Setting setting) { value_.Encode(name_, setting); return(value_.Encoded); }
protected override void OnSetValue(List <byte[]> values, SGF_Root_Setting setting) { value_.Decode(values, name_, setting); }
internal abstract List <byte[]> ToPropertyValues(SGF_Root_Setting setting);
protected abstract void OnSetValue(List <byte[]> values, SGF_Root_Setting setting);