Ejemplo n.º 1
0
        public static Box FromBoxStream(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            try
            {
                return(AmoebaConverter.FromStream <Box>(stream));
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Ejemplo n.º 2
0
        public static Stream ToBoxStream(Box item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            try
            {
                return(AmoebaConverter.ToStream <Box>(item));
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Ejemplo n.º 3
0
        public static string ToSeedString(Seed item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

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

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