Skip to main content

UserInfoAccess

A class in Root.Township, the global namespace.

A user given by id or username, looked up through Alta's web API on first use and cached. Console commands use it for user arguments. The API is gone, so lookups wait for the timeout unless a mod answers them.

Constructors​

MemberWhat it is
UserInfoAccess(int userIdentifier)Creates an UserInfoAccess from userInfo.
UserInfoAccess(string username)Creates an UserInfoAccess from userInfo.
UserInfoAccess(UserInfo userInfo)Creates an UserInfoAccess from userInfo.

Fields​

7 private and internal fields
MemberWhat it is
private bool hasSearchedTrue once a lookup has run, so later calls use the result.
private static Dictionary<int, UserInfo> idCacheStatic cache of looked-up users by ID, shared by all instances.
private bool isByUsernameTrue when made from a username rather than an ID.
private static Dictionary<string, UserInfo> nameCacheStatic cache of looked-up users by lower-case username.
private int userIdentifierThe user ID this access was made with, or the found user's ID.
private UserInfo userInfoBacking field for UserInfo. Null until a lookup finds the user.
private string usernameLower-cased username this access was made with.

Properties​

MemberWhat it is
UserInfo UserInfo { get; }The user info, or null before the lookup or if not found.
1 private and internal property
MemberWhat it is
private bool DoesUserExist { get; }True once a lookup found a user.

Methods​

MemberWhat it is
async Task<int> GetIdentifier()The user's id, looking it up if needed. -1 if not found.
async Task<string> GetUsername()The user's name, looking it up if needed. Empty if not found.
async Task<bool> IsValid()Looks up the user if needed and returns whether they exist.
string ProvidedArgument()The id or lowercased username it was made from.
2 private and internal methods
MemberWhat it is
private void AddToCache()Stores the found user in both the name and the ID cache. Probably throws if no user was found.
private async Task SearchForUserAsync()Looks the user up by name or ID, from the static cache or else the Alta web API.

Used in​

Members of other types that take, return or hold a UserInfoAccess: