Exemple #1
0
        public IRlpItem EncodeToRlp(dynamic obj)
        {
            if (this.Nullable && obj == null)
            {
                return(new RlpItem());
            }

            Int32 value    = 0;
            bool  canParse = Int32.TryParse(obj.ToString(), out value);

            if (canParse)
            {
                IRlpItem item = value.EncodeToRlpItem();
                if (this._maxBytes != 0 && item.RlpData.Length > this._maxBytes)
                {
                    throw new ArgumentException("Exceed the maximum maxbytes");
                }
                return(item);
            }
            else
            {
                throw new ArgumentException("value type invalid");
            }
        }