Example #1
0
        public static Box FromBoxStream(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            try
            {
                return(AmoebaConverter.FromStream <Box>(0, stream));
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Example #2
0
        public static Stream ToBoxStream(Box item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            try
            {
                return(AmoebaConverter.ToStream <Box>(0, item));
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Example #3
0
        public static string ToSeedString(Seed item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            try
            {
                using (var stream = AmoebaConverter.ToStream <Seed>(0, item))
                {
                    return("Seed:" + AmoebaConverter.ToBase64String(stream));
                }
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Example #4
0
        public static Seed FromSeedString(string item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            if (!item.StartsWith("Seed:"))
            {
                throw new ArgumentException("item");
            }

            try
            {
                using (var stream = AmoebaConverter.FromBase64String(item.Remove(0, "Seed:".Length)))
                {
                    return(AmoebaConverter.FromStream <Seed>(0, stream));
                }
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }