コード例 #1
0
        public static _XThisCache XFromCache(IMemoryCache cache, ISession session)
        {
            _XThisCache xthis = null;
            string      key   = session.GetString("this");

            cache.TryGetValue(key, out xthis);
            return(xthis);
        }
コード例 #2
0
        public static void XToCache(XObject xthis, IMemoryCache cache, ISession session, IStringLocalizer xstring)
        {
            string      key        = session.GetString("this");
            _XThisCache xthisCache = new _XThisCache(xthis, xstring);

            using (ICacheEntry entry = cache.CreateEntry(key))
            {
                entry.SetValue(xthisCache);
            }
        }
コード例 #3
0
        public static _XThisCache XAuthenticate(ClaimsPrincipal user, IMemoryCache cache, ISession session)
        {
            _XThisCache xthis = null;

            if (user.HasClaim(c => c.Type == "Type") && user.HasClaim(c => c.Type == "hashCode"))
            {
                Claim t = user.FindFirst(c => c.Type == "Type");
                Claim h = user.FindFirst(c => c.Type == "hashCode");
                xthis = XFromCache(cache, session);
            }
            return(xthis);
        }
コード例 #4
0
        public static bool XFromCache(_XThisCache xthis, string key, out List <XObject> xobjects, int?start, int?count)
        {
            bool res = false;

            xobjects = null;
            if (xthis.XParams.ContainsKey(key))
            {
                res = xthis.XParams.TryGetValue(key, out xobjects);
                if (res)
                {
                    xobjects = xobjects.GetRange(start.GetValueOrDefault(0), count.GetValueOrDefault(xobjects.Count));
                }
            }
            return(res);
        }
コード例 #5
0
        public static bool XToCache(_XThisCache xthis, string key, string objKey)
        {
            bool    res     = false;
            XObject xobject = _XObjectModel.XFromCache(xthis, objKey);

            if (xobject != null)
            {
                if (xthis.XParams.ContainsKey(key))
                {
                    List <XObject> xparams = null;
                    res = xthis.XParams.TryGetValue(key, out xparams);
                    if (res)
                    {
                        xparams.Add(xobject);
                    }
                }
            }
            return(res);
        }
コード例 #6
0
        public static XObject XFromRoute(RouteData route, _XThisCache cache, X x)
        {
            XObject xobject = null;

            if (route.Values.ContainsKey("hashCode"))
            {
                object obj = null;
                route.Values.TryGetValue("hashCode", out obj);
                XType xtype = _XTypeModel.XFromRoute(route, x);
                if (obj is string szHashCode && xtype != null)
                {
                    int hashCode = 0;
                    if (int.TryParse(szHashCode, out hashCode))
                    {
                        xobject = _XObjectModel.XFromCache(cache, xtype, hashCode);
                    }
                }
            }
            return(xobject);
        }
コード例 #7
0
 public _XThisModel(_XThisCache xcache)
 {
     XCache = xcache;
 }
コード例 #8
0
 public _XModel(_XThisCache t)
 {
     XThis = t;
 }