public object GetInstance() { object instance; if (repository.HasType(type)) { instance = repository.Get(type); } else { var constructor = GetConstructor(); var parameters = GetConstructorParameterValues(constructor); try { instance = constructor.Invoke(parameters); } catch (Exception exception) { throw new UnableToReadXMLTextException( string.Format("Exception thrown from contructor of type '{0}'.", type.FullName), exception); } } if (instance == null) { Exception exception = new UnableToReadXMLTextException( string.Format("Unable to create instance of type '{0}'.", type.FullName)); throw exception; } return(instance); }
// TODO: THIS NEEDS A REVAMP // The longer the instance exists, the bigger this page gets. Needs some form of paging or restriction public ActionResult Instance(int id = -1) { if (id == -1) { return(View("InvalidResource", model: "instance")); } var instance = _instanceRepository.Get(id); if (instance == null) { return(View("InvalidResource", model: "instance")); } bool returnAll = false; if (Request.IsAuthenticated) { if (User.IsInRole(UserGroups.Admin)) { returnAll = true; } } var model = new SessionInstanceVM { Instance = instance, Sessions = returnAll ? _sessionRepository.GetAllInstanceSessions(id) : _sessionRepository.GetInstanceSessions(id, User.Identity.GetUserId()) }; foreach (var guildSession in model.Sessions) { guildSession.BossesSeen = _sessionRepository.GetBossesKilled(guildSession.Id); guildSession.BossesSeenNotKilled = _sessionRepository.GetBossesSeenButNotKilled(guildSession.Id); } return(View(model)); }