private static UserHeader DeserializeUser(KeyValuePair<string, string>[] propertyBag)
 {
     return new UserHeader
     {
         Id = new Guid(propertyBag.First(item => item.Key == IdProperty).Value),
         Email = propertyBag.First(item => item.Key == EMailProperty).Value,
         Role = ParseRole(propertyBag.First(item => item.Key == RoleProperty).Value),
         FirstName = propertyBag.First(item => item.Key == FirstNameProperty).Value,
         LastName = propertyBag.First(item => item.Key == LastNameProperty).Value,
     };
 }
Example #2
0
        public override void OnNavigatedTo(KeyValuePair<string, string>[] argument = null)
        {
            Station station = App.AvailableStations.First(x => x.Title == argument.First(y => y.Key == "Station").Value);

            LoadSongHistory(station);

            base.OnNavigatedTo(argument);
        }
        public void loadObjects(KeyValuePair<string, string>[] objects)
        {
            cachedObjects = new JsDictionary<string, LevelObject>();

            foreach (LevelObjectInfo t in SonicLevel.Objects)
            {
                var o = t.Key;
                if (cachedObjects.ContainsKey(o))
                {
                    t.SetObjectData(cachedObjects[o]);
                    continue;
                }
                var d = objects.First(p => p.Key == o);
                if (d.Falsey())
                {
                    t.SetObjectData(new LevelObject(o));
                    continue;
                }
                LevelObjectData dat;
                if (d.Value.Length == 0) dat = new LevelObjectData();
                else dat = (LevelObjectData)Json.Parse(d.Value);

                var dr = ObjectManager.ExtendObject(dat);
                cachedObjects[o] = dr;
                t.SetObjectData(dr);
            }

            /* 
        OurSonic.SonicLevels.getObjects(objectKeys, function (objects) {
            window.CachedObjects = [];
            for (l = 0; l < sonicManager.SonicLevel.Objects.length; l++) {
                o = sonicManager.SonicLevel.Objects[l].key;
                if (window.CachedObjects[o]) {
                    sonicManager.SonicLevel.Objects[l].setObjectData(window.CachedObjects[o]);
                    continue;
                }
                var d = JSLINQ(objects).First(function (p) { return p.key == o; });
                if (!d) {
                    sonicManager.SonicLevel.Objects[l].setObjectData(new LevelObject(o));
                    continue;
                }

                var dr = _H.extend(new LevelObject(""), jQuery.parseJSON(d.value));
                dr = sonicManager.objectManager.extendObject(dr);

                for (var n = 0; n < dr.assets.length; n++) {
                    for (var s = 0; s < dr.assets[n].frames.length; s++) {
                        dr.assets[n].frames[s].hurtSonicMap.length = dr.assets[n].frames[s].width;
                        dr.assets[n].frames[s].collisionMap.length = dr.assets[n].frames[s].width;
                        for (var t = 0; t < dr.assets[n].frames[s].hurtSonicMap.length; t++) {
                            dr.assets[n].frames[s].hurtSonicMap[t].length = dr.assets[n].frames[s].height;
                            dr.assets[n].frames[s].collisionMap[t].length = dr.assets[n].frames[s].height;

                        }
                    }
                }

                window.CachedObjects[o] = dr;
                sonicManager.SonicLevel.Objects[l].setObjectData(dr);

            }

        });

*/
        }
        public void Should_not_loose_headers()
        {
            var headers = new KeyValuePair<string, string>[0];
            _bus.SubscribeContextHandler<A>(ctx =>
            {
                headers = ctx.Headers.ToArray();
                _receivedA.Set();
            });

            _bus.ScheduleMessage(1.Seconds().FromUtcNow(), new A { Name = "Joe" },
                ctx =>
                {
                    ctx.SetHeader("ATest", "AValue");
                });

            Assert.IsTrue(_receivedA.WaitOne(Utils.Timeout), "Message A not handled");
            Assert.IsNotEmpty(headers, "No Headers were sent");
            Assert.AreEqual("AValue", headers.First(h => h.Key == "ATest").Value);
        }