コード例 #1
0
        override protected IEnumerable <XElement> getSpecificData(WebContext context)
        {
            IUserSettings settings = AccountSettings.LoadByAccount(context.session.account);

            return(new XElement[] {
                settings.exportToXml(context),
                new XElement("skins", from skin in Skin.allSkins select skin.exportToXml()),
                new XElement("modernSkins", from modernSkin in ModernSkin.allSkins select modernSkin.exportToXml()),
                new XElement("machicharas", from machichara in Machichara.allMachicharas select machichara.exportToXml())
            });
        }
コード例 #2
0
        public WebContext(HttpContext httpcontext)
        {
            this.httpcontext = httpcontext;
            this.requestTime = DateTime.Now;
            this.design      = this.detectDesign();

            HttpCookie sessionCookie = this.httprequest.Cookies[Config.instance.CookiesPrefix + "_session"];

            if (sessionCookie != null && sessionCookie.Value != null && sessionCookie.Value != "")
            {
                try {
                    var    session = Session.LoadByKey(sessionCookie.Value);
                    var    tmp     = session.account;
                    string lastUrl = null;
                    if (this.httprequest.RequestType == "GET")
                    {
                        if (this.design.IsHuman)
                        {
                            lastUrl = this.httprequest.Path;
                        }
                    }
                    session.updateLastActivity(lastUrl);
                    HttpCookie newCookie = this.createCookie(Config.instance.CookiesPrefix + "_session");
                    newCookie.Value   = session.sessionKey;
                    newCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime);
                    this.httpresponse.AppendCookie(newCookie);
                    this.session = session;
                } catch (NotFoundInDBException) {
                    sessionCookie.Value   = "";
                    sessionCookie.Expires = DateTime.Now.AddDays(-1);
                    this.httpresponse.AppendCookie(sessionCookie);
                    //throw; //TODO: remove me!
                }
            }
            if (this.session != null)
            {
                this.userSettings = AccountSettings.LoadByAccount(this.session.account);
            }
            else
            {
                this.userSettings = new AnonymousUserSettings(null);
            }
        }