Пример #1
0
        public static string ToWikiString(Wiki item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Wiki");
            }

            try
            {
                using (Stream stream = OutoposConverter.ToStream <Wiki>(item))
                {
                    return("Wiki:" + OutoposConverter.ToBase64String(stream));
                }
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Пример #2
0
        public static string ToChatString(Chat item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("Chat");
            }

            try
            {
                using (Stream stream = OutoposConverter.ToStream <Chat>(item))
                {
                    return("Chat:" + OutoposConverter.ToBase64String(stream));
                }
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Пример #3
0
        public static string ToNodeString(Node item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            try
            {
                using (Stream stream = OutoposConverter.ToStream <Node>(item))
                {
                    return("Node:" + OutoposConverter.ToBase64String(stream));
                }
            }
            catch (Exception)
            {
                throw new FormatException();
            }
        }
Пример #4
0
        public static Chat FromChatString(string item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (!item.StartsWith("Chat:"))
            {
                throw new ArgumentException("item");
            }

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