예제 #1
0
        /// <inheritdoc />
        public override string ToString()
        {
            var stream = new OutfitChatLinkConverter().Convert(this, null);
            var buffer = new byte[stream.Length];

            stream.Read(buffer, 0, buffer.Length);
            return(string.Format("[&{0}]", Convert.ToBase64String(buffer)));
        }
예제 #2
0
        /// <inheritdoc />
        public ChatLink Convert(byte[] value, object state)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            using (var stream = new MemoryStream(value, false))
                using (var reader = new BinaryReader(stream))
                {
                    var header = reader.ReadByte();
                    IConverter <Stream, ChatLink> converter;
                    switch (header)
                    {
                    case 1:
                        converter = new CoinChatLinkConverter();
                        break;

                    case 2:
                        converter = new ItemChatLinkConverter();
                        break;

                    case 3:
                        converter = new DialogChatLinkConverter();
                        break;

                    case 4:
                        converter = new PointOfInterestChatLinkConverter();
                        break;

                    case 7:
                        converter = new SkillChatLinkConverter();
                        break;

                    case 8:
                        converter = new TraitChatLinkConverter();
                        break;

                    case 10:
                        converter = new RecipeChatLinkConverter();
                        break;

                    case 11:
                        converter = new SkinChatLinkConverter();
                        break;

                    case 12:
                        converter = new OutfitChatLinkConverter();
                        break;

                    default:
                        converter = new UnknownChatLinkConverter();
                        break;
                    }

                    return(converter.Convert(stream, value));
                }
        }