Exemplo n.º 1
0
        public void ManuallyComposedTypeWithMultipleTranslatorsHandlesMessageProperly()
        {
            var message3 = new Message3 {
                CorrelationId = "1234"
            };

            var      bus              = new Bus();
            Message4 message4         = null;
            var      message2Consumer = new MyConsumer();

            bus.AddHandler(message2Consumer);
            bus.AddHandler(new ActionConsumer <Message4>(m => message4 = m));
            var pipe = new Pipe();

            bus.AddTranslator(pipe);
            bus.AddTranslator(new ActionPipe <Message3, Message4>(m => new Message4 {
                CorrelationId = m.CorrelationId
            }));

            bus.Handle(message3);

            Assert.IsNotNull(message4);
            Assert.AreEqual(message3.CorrelationId, message4.CorrelationId);
            Assert.IsNotNull(Pipe.LastMessageProcessed);
            Assert.AreEqual(message3.CorrelationId, message4.CorrelationId);
        }
Exemplo n.º 2
0
        public void TestMessage4()
        {
            var vdm_message = new Vdm();
            var msg         = new Message4();


            var result = vdm_message.Add("!AIVDM,1,1,,A,403OwpiuIKl:Ro=sbvK=CG700<3b,0*5E");

            AssertEquals("vdm add failed", 0, result);
            msg.Parse(vdm_message.SixState);


            AssertEquals("msgid", 4, msg.MsgId);
            AssertEquals("repeat", 0, msg.Repeat);
            AssertEquals("userid", 3669987, msg.UserId);
            AssertEquals("utc_year", 2006, msg.UtcYear);
            AssertEquals("utc_month", 5, msg.UtcMonth);
            AssertEquals("utc_day", 23, msg.UtcDay);
            AssertEquals("utc_hour", 20, msg.UtcHour);
            AssertEquals("utc_minute", 10, msg.UtcMinute);
            AssertEquals("utc_second", 34, msg.UtcSecond);
            AssertEquals("pos_acc", 1, msg.PosAcc);
            AssertEquals("longitude", -73671329, msg.Pos.Longitude);
            AssertEquals("latitude", 28529500, msg.Pos.Latitude);
            AssertEquals("pos_type", 7, msg.PosType);
            AssertEquals("spare", 0, msg.Spare);
            AssertEquals("raim", 0, msg.Raim);
            AssertEquals("sync_state", 0, msg.SyncState);
            AssertEquals("slot_timeout", 3, msg.SlotTimeout);
            AssertEquals("sub_message", 234, msg.SubMessage);
        }
Exemplo n.º 3
0
        public async Task can_pass_in_the_invocation_context()
        {
            var message = new Message4();
            var context = await Execute(message);

            AsyncHandler.LastContext.ShouldBeSameAs(context);
        }
Exemplo n.º 4
0
 private void Message_OnClick2(object sender, RoutedEventArgs e)
 {
     Button btn = (Button)sender;
     var nmb = int.Parse(Regex.Replace(btn.Name, "[^0-9.]", ""));
     object ob = null;
     switch (nmb)
     {
         case 1:
             ob = new Message1();
             break;
         case 2:
             ob = new Message2();
             break;
         case 3:
             ob = new Message3();
             break;
         case 4:
             ob = new Message4();
             break;
         case 5:
             ob = new Message5();
             break;
     }
     if (ob != null)
         App.EventAgrigator.PublishOnCurrentThread(ob, "M1");
 }
Exemplo n.º 5
0
        private async void Initialize(string path)
        {
            _path = path;
            ThemePreview.Initialize(path);

            var flags = TelegramTheme.Light;

            var file = await StorageFile.GetFileFromPathAsync(path);

            var lines = await FileIO.ReadLinesAsync(file);

            foreach (var line in lines)
            {
                if (line.StartsWith("name: "))
                {
                    TitleLabel.Text = line.Substring("name: ".Length);
                }
                else if (line.StartsWith("parent: "))
                {
                    flags = (TelegramTheme)int.Parse(line.Substring("parent: ".Length));
                }
            }

            LayoutRoot.RequestedTheme = flags == TelegramTheme.Light ? ElementTheme.Light : ElementTheme.Dark;

            Chat1.Mockup(new ChatTypePrivate(), 0, "Eva Summer", string.Empty, "Reminds me of a Chinese proverb...", false, 0, false, true, DateTime.Now);
            Chat2.Mockup(new ChatTypePrivate(), 1, "Alexandra Smith", string.Empty, "This is amazing!", false, 2, false, false, DateTime.Now.AddHours(-1));
            Chat3.Mockup(new ChatTypePrivate(), 2, "Mike Apple", "😄 " + Strings.Resources.AttachSticker, string.Empty, false, 2, true, false, DateTime.Now.AddHours(-2), true);
            Chat4.Mockup(new ChatTypeSupergroup(), 3, "Evening Club", "Eva: " + Strings.Resources.AttachPhoto, string.Empty, false, 0, false, false, DateTime.Now.AddHours(-3));
            Chat5.Mockup(new ChatTypeSupergroup(), 4, "Old Pirates", "Max: ", "Yo-ho-ho!", false, 0, false, false, DateTime.Now.AddHours(-4));
            Chat6.Mockup(new ChatTypePrivate(), 5, "Max Bright", string.Empty, "How about some coffee?", true, 0, false, false, DateTime.Now.AddHours(-5));
            Chat7.Mockup(new ChatTypePrivate(), 6, "Natalie Parker", string.Empty, "OK, great)", true, 0, false, false, DateTime.Now.AddHours(-6));

            Photo.Source  = PlaceholderHelper.GetNameForUser(Strings.Resources.ThemePreviewTitle, 30);
            Title.Text    = Strings.Resources.ThemePreviewTitle;
            Subtitle.Text = string.Format("{0} {1} {2}", Strings.Resources.LastSeen, Strings.Resources.TodayAt, Converter.ShortTime.Format(DateTime.Now.AddHours(-1)));

            Message1.Mockup(new MessagePhoto(new Photo(false, null, new[] { new PhotoSize("i", TdExtensions.GetLocalFile("Assets\\Mockup\\theme_preview_image.jpg"), 500, 302, new int[0]) }), new FormattedText(), false), Strings.Resources.ThemePreviewLine4, false, DateTime.Now.AddSeconds(-25), true, true);
            Message2.Mockup(Strings.Resources.ThemePreviewLine1, true, DateTime.Now, true, false);
            //Message3.Mockup(Strings.Resources.FontSizePreviewLine1, Strings.Resources.FontSizePreviewName, Strings.Resources.FontSizePreviewReply, false, DateTime.Now.AddSeconds(-25));
            Message3.Mockup(new MessageVoiceNote(new VoiceNote(3, new byte[]
            {
                0, 0, 163, 198, 43, 17, 250, 248, 127, 155, 85, 58, 159, 230, 164, 212, 185, 247, 73, 42,
                173, 66, 165, 69, 41, 251, 255, 242, 127, 223, 113, 133, 237, 148, 243, 30, 127, 184, 206, 183, 234,
                108, 175, 168, 250, 207, 114, 229, 233, 154, 35, 254, 21, 66, 99, 134, 141, 92, 159, 2
            }, "audio/ogg", null, null), new FormattedText(), true), true, DateTime.Now.AddSeconds(-25), false, true);
            Message4.Mockup(Strings.Resources.ThemePreviewLine3, Strings.Resources.ThemePreviewLine3Reply, Strings.Resources.ThemePreviewLine1, false, DateTime.Now.AddSeconds(-25), true, false);
            Message5.Mockup(new MessageAudio(new Audio(4 * 60 + 3, Strings.Resources.ThemePreviewSongTitle, Strings.Resources.ThemePreviewSongPerformer, "preview.mp3", "audio/mp3", null, null, null, null), new FormattedText()), false, DateTime.Now, false, true);
            Message6.Mockup(Strings.Resources.ThemePreviewLine2, true, DateTime.Now, true, true);

            PrimaryButtonText   = Strings.Resources.ApplyTheme;
            SecondaryButtonText = Strings.Resources.Cancel;
        }
Exemplo n.º 6
0
 public void Handle(Message4 msg)
 {
 }
 public void Handle(Message4 message)
 {
 }
Exemplo n.º 8
0
        public static void CharacterRenameRequest(IRealmClient client, RealmPacketIn packet)
        {
            if (client.Account == null || client.ActiveCharacter != null)
                return;

            var guid = packet.ReadEntityId();
            var newName = packet.ReadCString();
            var record = client.Account.GetCharacterRecord(guid.Low);

            if (record == null)
            {
                log.Error(WCell_RealmServer.IllegalRenameAttempt, guid.ToString(), client);
            }
            else
            {
                if (record.CharacterFlags.HasFlag(CharEnumFlags.NeedsRename))
                {
                    // their character isn't flagged to be renamed, what do they think they're doing? ;)
                    client.Disconnect();
                }
                else
                {
                    LoginErrorCode errorCode = IsNameValid(ref newName);

                    if (errorCode != LoginErrorCode.RESPONSE_SUCCESS)
                    {
                        SendCharacterRenameError(client, errorCode);
                    }
                    else
                    {
                        log.Debug(WCell_RealmServer.RenamingCharacter, record.Name, newName);

                        record.Name = newName;

                        var charRenameTask =
                            new Message4<IRealmClient, CharacterRecord, string, EntityId>(CharacterRenameCallback)
                            {
                                Parameter1 = client,
                                Parameter2 = record,
                                Parameter3 = newName,
                                Parameter4 = guid
                            };

                        // only enqueue to IO Queue if we are in a map context?
                        RealmServer.IOQueue.AddMessage(charRenameTask);
                    }
                }
            }
        }
 public void Go7(Message4 thing, IService service)
 {
 }
Exemplo n.º 10
0
 public static Task Simple4(Message4 message, IInvocationContext context)
 {
     LastContext = context;
     return(Task.CompletedTask);
 }
Exemplo n.º 11
0
 public static Task Consumes(Message4 message, IMessageContext context)
 {
     LastContext = context;
     return(Task.CompletedTask);
 }