当前位置: 首页>>代码示例>>C#>>正文


C# Engine.MessageBuilder类代码示例

本文整理汇总了C#中Smuxi.Engine.MessageBuilder的典型用法代码示例。如果您正苦于以下问题:C# MessageBuilder类的具体用法?C# MessageBuilder怎么用?C# MessageBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageBuilder类属于Smuxi.Engine命名空间,在下文中一共展示了MessageBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Contains

        public void Contains()
        {
            Assert.IsTrue(Buffer.Contains(TestMessages[0]));

            var msg = new MessageBuilder();
            msg.AppendText("testfoo");
            Assert.IsFalse(Buffer.Contains(msg.ToMessage()));
        }
开发者ID:grendello,项目名称:smuxi,代码行数:8,代码来源:MessageBufferTestsBase.cs

示例2: AppendBrokenMail

 public void AppendBrokenMail()
 {
     var msg = "mailto:/[email protected]";
     var builder = new MessageBuilder();
     builder.TimeStamp = DateTime.MinValue;
     builder.Append(new TextMessagePartModel("mailto:/"));
     builder.Append(new UrlMessagePartModel("mailto:[email protected]", "[email protected]"));
     TestMessage(msg, builder.ToMessage());
 }
开发者ID:glwu,项目名称:smuxi,代码行数:9,代码来源:MessageBuilderTests.cs

示例3: Add

        public void Add()
        {
            MessageBuilder msg = new MessageBuilder();
            msg.AppendText("test");

            int count = Buffer.Count;
            Buffer.Add(msg.ToMessage());
            Assert.AreEqual(count + 1, Buffer.Count);
        }
开发者ID:NattyNarwhal,项目名称:smuxi,代码行数:9,代码来源:MessageBufferTestsBase.cs

示例4: BenchmarkWithUrl

 public void BenchmarkWithUrl()
 {
     int howOften = 5000;
     var nonurl = @"is this up to date? --> ";
     var url = @"http://www.stack.nl/~jilles/irc/atheme-help/";
     var withUrl = nonurl + url;
     var withoutUrl = @"Generated Sat Dec 11 21:29:16 CET 2010 -- old";
     var builder = new MessageBuilder();
     for (int i = 0; i < howOften; ++i) {
         builder.AppendMessage(withUrl);
     }
 }
开发者ID:pacificIT,项目名称:smuxi,代码行数:12,代码来源:MessageParserTests.cs

示例5: AppendHtmlMessageBold

        public void AppendHtmlMessageBold()
        {
            var builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            var textPart = builder.CreateText("Test");
            textPart.Bold = true;
            builder.Append(textPart);
            var expectedMsg = builder.ToMessage();

            builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendHtmlMessage("<b>Test</b>");
            var actualMsg = builder.ToMessage();
            Assert.AreEqual(expectedMsg, actualMsg);
        }
开发者ID:oli-obk,项目名称:smuxi,代码行数:15,代码来源:MessageBuilderTests.cs

示例6: AppendHtmlMessageCssFgRed

        public void AppendHtmlMessageCssFgRed()
        {
            var builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            var textPart = builder.CreateText("Test");
            textPart.ForegroundColor = new TextColor(255, 0, 0);
            builder.Append(textPart);
            var expectedMsg = builder.ToMessage();

            builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendHtmlMessage("<div style=\"color: #FF0000\">Test</div>");
            var actualMsg = builder.ToMessage();
            Assert.AreEqual(expectedMsg, actualMsg);
        }
开发者ID:oli-obk,项目名称:smuxi,代码行数:15,代码来源:MessageBuilderTests.cs

示例7: ParseUrlsSimple

        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);
        }
开发者ID:grendello,项目名称:smuxi,代码行数:15,代码来源:MessageParserTests.cs

示例8: AppendFormatNonIntegerBraceChaos

 public void AppendFormatNonIntegerBraceChaos()
 {
     // "{{" -> escaped brace, verbatim text
     // "{{" -> escaped brace, verbatim text
     // "virtual " -> verbatim text
     // "{" -> placeholder starts
     // "0" -> placeholder text
     // "}}" -> escaped brace, placeholder text
     // "}}" -> escaped brace, placeholder text
     // "}" -> placeholder ends
     // => invalid placeholder name "0}}"
     // (same behavior as String.Format)
     var builder = new MessageBuilder();
     builder.AppendFormat("{{{{virtual {0}}}}}", "hugs");
 }
开发者ID:RAOF,项目名称:smuxi,代码行数:15,代码来源:MessageBuilderTests.cs

示例9: ParseUrlsBrackets

        public void ParseUrlsBrackets()
        {
            var builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendText("foo <");
            builder.AppendUrl("http://example.com");
            builder.AppendText("> bar");
            var expectedMsg = builder.ToMessage();

            builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendMessage("foo <http://example.com> bar");
            var actualMsg = builder.ToMessage();

            Assert.AreEqual(expectedMsg, actualMsg);
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:16,代码来源:MessageParserTests.cs

示例10: ImplicitRemoveAt

        public void ImplicitRemoveAt()
        {
            Buffer.MaxCapacity = 16;
            // generate 32 extra messsages to exceed the max capacity which
            // forces a RemoveAt() call of the oldest messages
            var bufferCount = Buffer.Count;
            var msgs = new List<MessageModel>(Buffer);
            for (int i = 1; i <= 32; i++) {
                var builder = new MessageBuilder();
                builder.AppendText("msg{0}", bufferCount + i);
                var msg = builder.ToMessage();
                msgs.Add(msg);
                Buffer.Add(msg);
            }

            Assert.AreEqual(Buffer.MaxCapacity, Buffer.Count);
            Assert.AreEqual(msgs[32 - (Buffer.MaxCapacity - bufferCount)].ToString(), Buffer[0].ToString());
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:18,代码来源:Db4oMessageBufferTests.cs

示例11: AppendHtmlMessageCssFgRedBgBlue

        public void AppendHtmlMessageCssFgRedBgBlue()
        {
            var builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            var textPart = builder.CreateText("Test");
            textPart.ForegroundColor = new TextColor(255, 0, 0);
            textPart.BackgroundColor = new TextColor(0, 0, 255);
            builder.Append(textPart);
            var expectedMsg = builder.ToMessage();

            builder = new MessageBuilder();
            builder.TimeStamp = DateTime.MinValue;
            builder.AppendHtmlMessage(
                "<div style=\"" +
                    "color: #FF0000; " +
                    "background: #0000FF url('smiley.gif') no-repeat fixed center" +
                "\">Test</div>");
            var actualMsg = builder.ToMessage();
            Assert.AreEqual(expectedMsg, actualMsg);
        }
开发者ID:oli-obk,项目名称:smuxi,代码行数:20,代码来源:MessageBuilderTests.cs

示例12: ImplicitFlush

        public void ImplicitFlush()
        {
            // generate 32 extra messsages to exceed the buffer size which
            // forces a flush of the buffer to db4o
            var bufferCount = Buffer.Count;
            var msgs = new List<MessageModel>(Buffer);
            for (int i = 1; i <= 32; i++) {
                var builder = new MessageBuilder();
                builder.AppendText("msg{0}", bufferCount + i);
                var msg = builder.ToMessage();
                msgs.Add(msg);
                Buffer.Add(msg);
            }

            int j = 0;
            foreach (var msg in Buffer) {
                Assert.AreEqual(msgs[j++].ToString(), msg.ToString());
            }
            Assert.AreEqual(msgs.Count, j);
        }
开发者ID:pacificIT,项目名称:smuxi,代码行数:20,代码来源:Db4oMessageBufferTests.cs

示例13: AddMessage

        public void AddMessage(MessageModel msg, bool addLinebreak, bool showTimestamps)
        {
            #if MSG_DEBUG
            Trace.Call(msg, addLinebreak);
            #endif

            if (msg == null) {
                throw new ArgumentNullException("msg");
            }

            var buffer = Buffer;
            var iter = buffer.EndIter;
            var startMark = new Gtk.TextMark(null, true);
            buffer.AddMark(startMark, iter);

            var senderPrefixWidth = GetSenderPrefixWidth(msg);
            Gtk.TextTag indentTag = null;
            if (senderPrefixWidth != 0) {
                // TODO: re-use text tags that have the same indent width
                indentTag = new Gtk.TextTag(null) {
                    Indent = -senderPrefixWidth
                };
                _MessageTextTagTable.Add(indentTag);
            }

            if (showTimestamps) {
                var msgTimeStamp = msg.TimeStamp.ToLocalTime();
                if (_LastMessage != null) {
                    var lastMsgTimeStamp = _LastMessage.TimeStamp.ToLocalTime();
                    var span = msgTimeStamp.Date - lastMsgTimeStamp.Date;
                    if (span.Days > 0) {
                        var dayLine = new MessageBuilder().
                            AppendEventPrefix();
                        if (span.Days > 1) {
                            dayLine.AppendText(_("Day changed from {0} to {1}"),
                                               lastMsgTimeStamp.ToShortDateString(),
                                               msgTimeStamp.ToShortDateString());
                        } else {
                            dayLine.AppendText(_("Day changed to {0}"),
                                               msgTimeStamp.ToLongDateString());
                        }
                        dayLine.AppendText("\n");
                        var dayLineMsg = dayLine.ToMessage().ToString();
                        Buffer.InsertWithTags(ref iter, dayLineMsg, EventTag);
                    }
                }

                string timestamp = null;
                try {
                    string format = (string)Frontend.UserConfig["Interface/Notebook/TimestampFormat"];
                    if (!String.IsNullOrEmpty(format)) {
                        timestamp = msgTimeStamp.ToString(format);
                    }
                } catch (FormatException e) {
                    timestamp = "Timestamp Format ERROR: " + e.Message;
                }

                if (timestamp != null) {
                    timestamp = String.Format("{0} ", timestamp);
                    buffer.Insert(ref iter, timestamp);

                    // apply timestamp width to indent tag
                    if (indentTag != null) {
                        indentTag.Indent -= GetPangoWidth(timestamp);
                    }
                }
            }

            var msgStartMark = new Gtk.TextMark(null, true);
            buffer.AddMark(msgStartMark, iter);

            bool hasHighlight = false;
            foreach (MessagePartModel msgPart in msg.MessageParts) {
                // supposed to be used only in a ChatView
                if (msgPart.IsHighlight) {
                    hasHighlight = true;
                }

                // TODO: implement all types
                if (msgPart is UrlMessagePartModel) {
                    var urlPart = (UrlMessagePartModel) msgPart;
                    var linkText = urlPart.Text ?? urlPart.Url;

                    var url = urlPart.Url;
                    Uri uri;
                    try {
                        uri = new Uri(url);
                    } catch (UriFormatException ex) {
            #if LOG4NET
                        _Logger.Error("AddMessage(): Invalid URL: " + url, ex);
            #endif
                        buffer.Insert(ref iter, linkText);
                        continue;
                    }

                    var tags = new List<Gtk.TextTag>();
                    // link URI tag
                    var linkTag = new LinkTag(uri);
                    linkTag.TextEvent += OnLinkTagTextEvent;
                    _MessageTextTagTable.Add(linkTag);
//.........这里部分代码省略.........
开发者ID:RAOF,项目名称:smuxi,代码行数:101,代码来源:MessageTextView.cs

示例14: FormatEvent

 void FormatEvent(MessageBuilder bld, PersonModel person, string action)
 {
     bld.AppendEventPrefix();
     bld.AppendIdendityName(person).AppendSpace();
     bld.AppendText(action);
 }
开发者ID:glwu,项目名称:smuxi,代码行数:6,代码来源:CampfireProtocolManager.cs

示例15: FormatUpload

        void FormatUpload(MessageBuilder bld, PersonModel person, ChatModel chat, Message message)
        {
            // Figure out what the user uploaded, we need to issue another call for this
            var upload = Client.Get<UploadWrapper>(String.Format("/room/{0}/messages/{1}/upload.json", chat.ID, message.Id)).Upload;

            bld.AppendEventPrefix();
            bld.AppendIdendityName(person).AppendSpace();
            bld.AppendText(_("has uploaded '{0}' ({1} B) {2}"), upload.Name, upload.Byte_Size, upload.Full_Url);
        }
开发者ID:glwu,项目名称:smuxi,代码行数:9,代码来源:CampfireProtocolManager.cs


注:本文中的Smuxi.Engine.MessageBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。