public static _XThisCache XFromCache(IMemoryCache cache, ISession session) { _XThisCache xthis = null; string key = session.GetString("this"); cache.TryGetValue(key, out xthis); return(xthis); }
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); } }
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); }
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); }
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); }
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); }
public _XThisModel(_XThisCache xcache) { XCache = xcache; }
public _XModel(_XThisCache t) { XThis = t; }