Esempio n. 1
0
        public void CanISetAllPropertiesFromApplicationModel()
        {
            var _sut = new SessionModel()
            {
                RegistrationDate               = new DateTime(2017, 1, 1),
                SessionsControl_Id             = 1,
                DateTimeToControlRequestLimist = new DateTime(2017, 1, 1),
                RequestCountByMinute           = 1,
                RequestLimitExceded            = true,
                LastValidToken = "123456789",
                Application_Id = "123456789",
                Application    = new ApplicationModel()
                {
                    Application_Id = "123456789"
                }
            };

            Assert.AreEqual(8, _sut.GetType().GetProperties().Count());
            Assert.AreEqual("123456789", _sut.Application_Id);
            Assert.AreEqual("123456789", _sut.Application.Application_Id);
            Assert.AreEqual(new DateTime(2017, 1, 1), _sut.DateTimeToControlRequestLimist);
            Assert.AreEqual(1, _sut.SessionsControl_Id);
            Assert.AreEqual(1, _sut.RequestCountByMinute);
            Assert.AreEqual(true, _sut.RequestLimitExceded);
            Assert.AreEqual("123456789", _sut.LastValidToken);
        }
Esempio n. 2
0
        public SessionModel getSession()
        {
            SessionModel sm = new SessionModel();

            foreach (PropertyInfo pi in sm.GetType().GetProperties())
            {
                pi.SetValue(sm, session.GetString(pi.Name));
            }
            return(sm);
        }
Esempio n. 3
0
        public static SessionModel getCache()
        {
            SessionModel sm = new SessionModel();

            foreach (PropertyInfo pi in sm.GetType().GetProperties())
            {
                string str;
                cache.TryGetValue(pi.Name, out str);
                pi.SetValue(sm, str);
            }
            return(sm);
        }
Esempio n. 4
0
        public SessionModel getSession()
        {
            if (session == null)
            {
                //return null;
                throw new Exception("session为空");
            }
            SessionModel sm = new SessionModel();

            foreach (PropertyInfo pi in sm.GetType().GetProperties())
            {
                pi.SetValue(sm, session.GetString(pi.Name));
            }
            return(sm);
        }