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


C# Message.Commit方法代码示例

本文整理汇总了C#中Message.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# Message.Commit方法的具体用法?C# Message.Commit怎么用?C# Message.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message的用法示例。


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

示例1: FullModeRemove

        public void FullModeRemove()
        {
            var keep = new MessageKeep();
            keep.QuickMode = false;

            var message = new Message("Test");
            message.Init("Field", 1, 2, 3);

            message.Commit(this);

            Assert.IsFalse(message.IsEmpty);

            keep.Add(message);

            Assert.IsFalse(message.IsChanged);
            Assert.IsTrue(keep.IsChanged); // message was added

            keep.Sync();

            message.Remove("Field");

            Assert.IsTrue(message.IsChanged);
            Assert.IsTrue(keep.IsChanged);

            IEnumerable<int> changedIndices;
            var change = keep.Sync(out changedIndices);
            var diff = change.First();

            Assert.IsFalse(message.IsChanged);
            Assert.IsFalse(keep.IsChanged);

            Assert.IsTrue(diff.IsEmpty);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:33,代码来源:Keep.cs

示例2: FullModeTopic

        public void FullModeTopic()
        {
            var keep = new MessageKeep();
            keep.QuickMode = false;

            var message = new Message("Test");
            message.Commit(this);

            keep.Add(message);

            Assert.IsFalse(message.IsChanged);
            Assert.IsTrue(keep.IsChanged); // message was added

            keep.Sync();

            Assert.IsFalse(keep.IsChanged);

            message.Topic = "Refresh";

            Assert.IsTrue(message.IsChanged);
            Assert.IsTrue(keep.IsChanged);

            IEnumerable<int> changedIndices;
            var change = keep.Sync(out changedIndices);
            var diff = change.First();

            Assert.IsFalse(message.IsChanged);
            Assert.IsFalse(keep.IsChanged);

            Assert.AreEqual(message.Topic, diff.Topic);
            Assert.IsTrue(diff.IsEmpty);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:32,代码来源:Keep.cs

示例3: WithDetails

        public void WithDetails()
        {
            var message = new Message("Test");

            List<Message> diffs = new List<Message>();

            // will be notified on sync only
            message.Init("Field", 1, 2, 3);

            // set up anonymous watcher, simply recording all changes
            message.ChangedWithDetails += (orig, diff) => { diffs.Add(diff); };

            Assert.IsTrue(message.IsChanged);
            Assert.AreEqual(0, diffs.Count);

            var hasChanged = message.Commit(this);
            Assert.IsTrue(hasChanged);

            // notification received
            Assert.AreEqual(1, diffs.Count);

            // change corresponds
            Assert.AreEqual(message.Topic, diffs.First().Topic);
            Assert.AreEqual((Bin<int>)message["Field"], diffs.First()["Field"]);

            Assert.IsFalse(message.IsChanged);

            // sync again, should stay silent this time
            hasChanged = message.Commit(this);
            Assert.IsFalse(hasChanged);
            Assert.AreEqual(1, diffs.Count);

            message.Topic = "ChangedTopic";
            message.Init("Other", 1.68, 3.14);

            // sync again, check changes
            hasChanged = message.Commit(this);
            Assert.IsTrue(hasChanged);
            Assert.AreEqual(2, diffs.Count);

            // change corresponds
            Assert.AreEqual(message.Topic, diffs.Last().Topic);
            Assert.AreEqual((Bin<double>)message["Other"], diffs.Last()["Other"]);

            // really only "Other"
            Assert.AreEqual(1, diffs.Last().Fields.Count());
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:47,代码来源:ChangeEvents.cs

示例4: Test

 void Test(Room room)
 {
     // Create and post the message.
     var message = new Message(room);
     message.Text = "Test Message";
     StartCoroutine(message.Commit(error => {
         IntegrationTest.Fail(error.Message);
     }, success => {
         TearDown(room);
     }));
 }
开发者ID:RichLogan,项目名称:CiscoSpark-UnitySDK,代码行数:11,代码来源:TestCreateMessage.cs

示例5: TopicWithDetails

        public void TopicWithDetails()
        {
            var message = new Message("Test");

            List<Message> diffs = new List<Message>();

            message.Init("Field", 1, 2, 3);
            message.Commit(this); // clear now

            // set up anonymous watcher, simply recording all changes
            message.ChangedWithDetails += (orig, diff) => { diffs.Add(diff); };

            Assert.IsFalse(message.IsChanged);

            message.Topic = "OtherTopic";

            var hasChanged = message.Commit(this);
            Assert.IsTrue(hasChanged);

            // notification received
            Assert.AreEqual(1, diffs.Count);

            // change corresponds
            Assert.AreEqual(message.Topic, diffs.First().Topic);

            Assert.IsTrue(diffs.Last().IsEmpty);
            Assert.IsFalse(message.IsChanged);

            message.Topic = "  OtherTopic   "; // adding whitespaces should not matter
            Assert.AreEqual("OtherTopic", message.Topic);

            Assert.IsFalse(message.IsChanged);

            // sync again, should stay silent this time
            hasChanged = message.Commit(this);
            Assert.IsFalse(hasChanged);
            Assert.AreEqual(1, diffs.Count);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:38,代码来源:ChangeEvents.cs

示例6: AssignFromTest

        public void AssignFromTest()
        {
            var name = "field";
            var m = new Message("topic");
            m.Commit(this);

            Assert.IsFalse(m.IsChanged);
            var data = Enumerable.Repeat(4, 4);
            m.AssignFrom(name, data);

            Assert.IsTrue(m.IsChanged);

            Assert.AreEqual(m[name], BinFactory.New(4, 4, 4, 4));
            Assert.AreEqual(m[name].Count, 4);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:15,代码来源:MessageTest.cs

示例7: SetUp

 void SetUp()
 {
     // Need a test room.
     var room = new Room("Unity SDK Test Room", null);
     StartCoroutine(room.Commit(error => {
         IntegrationTest.Fail("Failed to create test room: " + error.Message);
     }, success => {
         // Need a test message.
         var testMessage = new Message(room);
         testMessage.Text = "Test Message";
         StartCoroutine(testMessage.Commit(messageError => {
             IntegrationTest.Fail("Failed to create Test Message: " + messageError.Message);
         }, messageSuccess => {
             Test(testMessage);
         }));
     }));
 }
开发者ID:RichLogan,项目名称:CiscoSpark-UnitySDK,代码行数:17,代码来源:TestLoadMessage.cs

示例8: SetUp

 void SetUp()
 {
     // We need a test room for the messages.
     testRoom = new Room("Unity SDK Test Room", null);
     StartCoroutine(testRoom.Commit(error =>
     {
         IntegrationTest.Fail("Failed to create test room" + error.Message);
     }, success =>
     {
         // Need a message to look for.
         testMessage = new Message(testRoom);
         testMessage.Text = "Test Message";
         StartCoroutine(testMessage.Commit(error =>
         {
             TearDown();
             IntegrationTest.Fail("Failed to create test message: " + error.Message);
         }, createMessage =>
         {
             Test();
         }));
     }));
 }
开发者ID:RichLogan,项目名称:CiscoSpark-UnitySDK,代码行数:22,代码来源:TestListMessages.cs

示例9: CreateMessage

 void CreateMessage()
 {
     // Create Temporary Test Room.
     testRoom = new Room("Cisco Spark Unity Test Room", null);
     var roomCommit = testRoom.Commit(error =>
     {
         Debug.LogError("Couldn't create test room: " + error.Message);
     }, testRoomCreated =>
     {
         var testMessage = new Message(testRoom);
         testMessage.Text = testMessageContent;
         var messageCommit = testMessage.Commit(messageError =>
         {
             Debug.LogError("Create Message Failed: " + messageError.Message);
         }, createMessageSuccess =>
         {
             GetMessage(testMessage.Id);
         });
         StartCoroutine(messageCommit);
     });
     StartCoroutine(roomCommit);
 }
开发者ID:RichLogan,项目名称:CiscoSpark-UnitySDK,代码行数:22,代码来源:TestMessage.cs

示例10: TestInjectWithNew

        public void TestInjectWithNew()
        {
            var a = new Message("Topic");
            a.Init("Field", 1, 2);

            var b = new Message("Topic");
            b.Init("Field", 1, 2);
            b.Init("Other", 1, 2);

            a.Commit(this);

            a.InjectWith(b, true);

            Assert.IsTrue(a.IsChanged);
            Assert.IsFalse(a["Field"].IsChanged);

            Assert.AreEqual(a["Field"], b["Field"]);
            Assert.AreEqual(a["Other"], b["Other"]);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:19,代码来源:MessageTest.cs

示例11: TestInjectDeepWithDifference

        public void TestInjectDeepWithDifference()
        {
            var a = new Message("Topic");
            a.Init("Field", 1, 2);

            var b = new Message("Topic");
            b.Init("Field", 1, 2, 3); // slightly different

            a.Commit(this);

            a.InjectWith(b, true);

            Assert.IsTrue(a.IsChanged);
            Assert.AreEqual(a["Field"], b["Field"]);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:15,代码来源:MessageTest.cs

示例12: RenameTestOverwrite

        public void RenameTestOverwrite()
        {
            var name = "field";
            var newName = "newName";
            var m = new Message("topic");
            m.Init(newName, 1);
            m.Init(name, 4,4,4,4);
            m.Commit(this);

            Assert.IsFalse(m.IsChanged);
            m.Rename(name, newName, true);

            Assert.IsTrue(m.IsChanged);
            Assert.AreEqual(m[newName], BinFactory.New(4, 4, 4, 4));
            Assert.AreEqual(m[newName].Count, 4);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:16,代码来源:MessageTest.cs

示例13: InitTest

        public void InitTest()
        {
            var name = "field";
            var m = new Message("topic");
            m.Commit(this);

            Assert.IsFalse(m.IsChanged);
            m.Init(name, 1, 2, 3, 4);
            Assert.IsTrue(m.IsChanged);

            Assert.AreEqual(m[name], BinFactory.New(1, 2, 3, 4));
            Assert.AreEqual(m[name].Count, 4);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:13,代码来源:MessageTest.cs

示例14: EmptyAndRename

        public void EmptyAndRename()
        {
            var m = new Message("topic");

            Assert.IsTrue(m.IsEmpty);

            m.Init("field", 1, 2);
            var c = m.Commit(this);
            Assert.IsTrue(c);

            Assert.IsFalse(m.IsChanged);
            Assert.IsFalse(m.IsEmpty);

            m.Remove("field");
            Assert.IsTrue(m.IsEmpty);
            Assert.IsTrue(m.IsChanged);

            c = m.Commit(this);
            Assert.IsTrue(c);

            c = m.Commit(this);
            Assert.IsFalse(c);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:23,代码来源:MessageTest.cs

示例15: WithoutDetails

        public void WithoutDetails()
        {
            var message = new Message("Test");

            // fresh message is always changed until first sync
            Assert.IsTrue(message.IsChanged);

            var count = 0;
            message.Changed += orig => count++;

            // report ctor change of Message now
            var hasChanged = message.Commit(this);
            Assert.IsTrue(hasChanged);
            Assert.AreEqual(1, count);

            message.Init("Field", "a", "b", "c");

            // report next one
            hasChanged = message.Commit(this);
            Assert.IsTrue(hasChanged);
            Assert.AreEqual(2, count);

            // stay silent, because no change
            hasChanged = message.Commit(this);
            Assert.IsFalse(hasChanged);
            Assert.AreEqual(2, count);
        }
开发者ID:velcrome,项目名称:vvvv-Message,代码行数:27,代码来源:ChangeEvents.cs


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