コード例 #1
0
ファイル: MessageBuilder.cs プロジェクト: RAOF/smuxi
 public MessageModel ToMessage()
 {
     //MessageParser.ParseSmileys
     MessageParser.ParseUrls(Message);
     Message.Compact();
     return(Message);
 }
コード例 #2
0
        public void ParseUrlsSimple()
        {
            var builder = new MessageBuilder();

            builder.TimeStamp = DateTime.MinValue;
            builder.AppendUrl("http://example.com");
            var expectedMsg = builder.ToMessage();

            builder           = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendText("http://example.com");
            var actualMsg = builder.ToMessage();

            MessageParser.ParseUrls(actualMsg);

            Assert.AreEqual(expectedMsg, actualMsg);
        }
コード例 #3
0
ファイル: MessageModelTests.cs プロジェクト: licnep/smuxi
        public void CompactBenchmark()
        {
            var formatter = new BinaryFormatter();
            var topic     = "Smuxi the IRC client for sophisticated users: http://smuxi.org/ | Smuxi 0.7.2.2 'Lovegood' released (2010-07-27) http://bit.ly/9nvsZF | FAQ: http://smuxi.org/faq/ | Deutsch? -> #smuxi.de | Español? -> #smuxi.es | Smuxi @ FOSDEM 2010 talk: http://bit.ly/anHJfm";
            var msg       = new MessageModel(topic)
            {
                IsCompactable = false
            };

            MessageParser.ParseUrls(msg);

            var stream = new MemoryStream(1024);

            formatter.Serialize(stream, msg);
            Console.WriteLine("Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Size: " + stream.Length);

            msg.Compact();
            stream = new MemoryStream(1024);
            formatter.Serialize(stream, msg);
            Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Compacted Size: " + stream.Length);


            // regular message without URL
            // <meebey> solange eine message aber keine url hat ist der vorteil nur gering (wenn ueberhaupt)
            msg = new MessageModel()
            {
                IsCompactable = false
            };
            msg.MessageParts.Add(new TextMessagePartModel("<"));
            msg.MessageParts.Add(
                new TextMessagePartModel(
                    TextColor.White, null, false, false, false, "meebey"
                    )
                );
            msg.MessageParts.Add(new TextMessagePartModel("> "));
            msg.MessageParts.Add(
                new TextMessagePartModel(
                    "solange eine message aber keine url hat ist der " +
                    "vorteil nur gering (wenn ueberhaupt)"
                    )
                );
            stream = new MemoryStream(1024);
            formatter.Serialize(stream, msg);
            Console.WriteLine("Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Size: " + stream.Length);

            msg.Compact();
            stream = new MemoryStream(1024);
            formatter.Serialize(stream, msg);
            Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Compacted Size: " + stream.Length);


            // regular short message with URL
            // <meebey> http://www.smuxi.org/issues/show/107 kannst ja watchen
            msg = new MessageModel()
            {
                IsCompactable = false
            };
            msg.MessageParts.Add(new TextMessagePartModel("<"));
            msg.MessageParts.Add(
                new TextMessagePartModel(
                    TextColor.White, null, false, false, false, "meebey"
                    )
                );
            msg.MessageParts.Add(new TextMessagePartModel("> "));
            msg.MessageParts.Add(
                new UrlMessagePartModel(
                    "http://www.smuxi.org/issues/show/107"
                    )
                );
            msg.MessageParts.Add(new TextMessagePartModel(" kannst ja watchen"));
            MessageParser.ParseUrls(msg);

            stream = new MemoryStream(1024);
            formatter.Serialize(stream, msg);
            Console.WriteLine("Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Size: " + stream.Length);

            msg.Compact();
            stream = new MemoryStream(1024);
            formatter.Serialize(stream, msg);
            Console.WriteLine("Compacted Parts: " + msg.MessageParts.Count);
            Console.WriteLine("Compacted Size: " + stream.Length);
        }