mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-10-01 05:36:56 -05:00
Pass a Pokedex instance to the GtsRecord ctors
This commit is contained in:
30
web/src/AppStateHelper.cs
Normal file
30
web/src/AppStateHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user