コード例 #1
0
        /// <inheritdoc />
        public override string ToString()
        {
            var stream = new DialogChatLinkConverter().Convert(this, null);
            var buffer = new byte[stream.Length];

            stream.Read(buffer, 0, buffer.Length);
            return(string.Format("[&{0}]", Convert.ToBase64String(buffer)));
        }
コード例 #2
0
ファイル: ChatLinkConverter.cs プロジェクト: Waevka/GW2.NET
        /// <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));
                }
        }