mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-08-03 00:20:29 -05:00
30 lines
809 B
C#
30 lines
809 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using PkmnFoundations.Data;
|
|
|
|
namespace PkmnFoundations.Web
|
|
{
|
|
public static class AppStateHelper
|
|
{
|
|
public static Pokedex.Pokedex Pokedex(HttpApplicationState application)
|
|
{
|
|
return GetTypedApplicationObject(application, "pkmncfPokedex", () => new Pokedex.Pokedex(Database.Instance, false));
|
|
}
|
|
|
|
public static T GetTypedApplicationObject<T>(HttpApplicationState application, String key, Func<T> initializer) where T : class
|
|
{
|
|
object o = application[key];
|
|
T t = o as T;
|
|
|
|
if (t == null)
|
|
{
|
|
t = initializer();
|
|
application.Add(key, t);
|
|
}
|
|
|
|
return t;
|
|
}
|
|
}
|
|
} |