private static string Solve(string fn) { LocalCache <string> .Dictionary c = CACHE[typeof(T)]; string root = c.ContainsKey(".") ? c["."] : (c["."] = CalculateRoot()); return(Path.Combine(root, fn)); }
private GenDataDef AddDef(string def) { var f = def.ToLowerInvariant().Replace('/', '\\'); GenDataDef d; if (f.Equals("minimal")) { if (!LocalCache.ContainsKey(f)) { d = GenDataDef.CreateMinimal(); LocalCache.Add(f, d); } else { d = LocalCache[f]; } } else if (!LocalCache.ContainsKey(f)) { d = GenDataBase.DataLoader.LoadData(f).AsDef(); LocalCache.Add(f, d); } else { d = LocalCache[f]; } return(d); }
private SessionValue FetchSessionValue(string key, out bool cached) { cached = false; if (LocalCache.ContainsKey(key)) { String value = LocalCache[key].ToString(); if (!String.IsNullOrWhiteSpace(value)) { cached = true; return(new SessionValue { Name = key, Value = value }); } } var sv = db.SessionValues.FirstOrDefault(v => v.SessionId == CurrentSessionId && v.Name == key); if (sv != null) { LocalCache[key] = sv.Value; } return(sv); }
public static string Solve(string fn) { LocalCache <string> .Dictionary c = CACHE[typeof(T)]; if (c.ContainsKey(fn)) { return(c[fn]); } string r = SourceDir(fn); r = hackPath(r); return(c[fn] = r); }
/// <summary> /// Cache a data file programatically. /// </summary> /// <param name="name">The name of the cached data.</param> /// <param name="genDataDef">The data being cached.</param> /// <returns></returns> public void Internal(string name, GenDataDef genDataDef) { var n = name.ToLowerInvariant().Replace('/', '\\'); if (n.Equals("self")) { throw new ArgumentException("The 'self' generator data cannot be added explicitly to the cache", "name"); } if (!LocalCache.ContainsKey(n)) { LocalCache.Add(n, genDataDef); } }
public static string SourceDir(string fn) { LocalCache <string> .Dictionary c = CACHE_BASE[typeof(T)]; if (c.ContainsKey(fn)) { return(c[fn]); } string r = IO.Hierarchy <T> .GAMEDATA.SolveFull(false, "Assets"); // Hack dos infernos. :( Perhaps this Assets stunt isn't a good idea after all. :/ if (SIO.File.Exists(r)) { r = IO.Hierarchy <T> .GAMEDATA.SolveFull(false, "Assets", fn); } else { r = IO.Hierarchy <T> .GAMEDATA.SolveFull(false, fn); } r = hackPath(r, false); return(c[fn] = r); }
/// <summary> /// Check if the cache does not contain the data, and adds it then returns the cached data. /// </summary> /// <param name="defPath">The data's definition location.</param> /// <returns></returns> public GenDataDef this[string defPath] { get { if (defPath.Equals("self", StringComparison.InvariantCultureIgnoreCase)) { return(Self); } var f = AddDef(defPath); return(f); } set { var path = defPath.ToLowerInvariant(); if (!defPath.Equals("self", StringComparison.InvariantCultureIgnoreCase) && !LocalCache.ContainsKey(path)) { LocalCache.Add(path, value); } } }
/// <summary> /// Does the cache contain the referenced data /// </summary> /// <param name="reference"></param> /// <returns></returns> public bool Contains(string reference) { var d = reference.ToLowerInvariant().Replace('/', '\\'); return(d == "self" || _localCache != null && LocalCache.ContainsKey(d)); }
internal static string CalculateTypeRoot() { LocalCache <string> .Dictionary c = CACHE[typeof(T)]; return(c.ContainsKey(".") ? c["."] : (c["."] = calculateTypeRoot())); }