/********* ** Public methods *********/ /**** ** Token management ****/ /// <summary>Construct an instance.</summary> /// <param name="scope">The namespace for tokens specific to this mod.</param> /// <param name="parentContext">The parent token context.</param> public ModTokenContext(string scope, IContext parentContext) { this.Scope = scope; this.ParentContext = parentContext; this.LocalContext = new GenericTokenContext(this.IsModInstalled); this.DynamicContext = new GenericTokenContext(this.IsModInstalled); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="contentHelper">The content helper from which to load data assets.</param> /// <param name="installedMods">The installed mod IDs.</param> /// <param name="modTokens">The custom tokens provided by mods.</param> public TokenManager(IContentHelper contentHelper, InvariantHashSet installedMods, IEnumerable <IToken> modTokens) { this.InstalledMods = installedMods; this.GlobalContext = new GenericTokenContext(this.IsModInstalled); foreach (IToken modToken in modTokens) { this.GlobalContext.Tokens[modToken.Name] = modToken; } foreach (IValueProvider valueProvider in this.GetGlobalValueProviders(contentHelper, installedMods)) { this.GlobalContext.Tokens[valueProvider.Name] = new GenericToken(valueProvider); } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="contentHelper">The content helper from which to load data assets.</param> /// <param name="installedMods">The installed mod IDs.</param> /// <param name="modTokens">The custom tokens provided by mods.</param> /// <param name="reflection">Simplifies access to private code.</param> public TokenManager(IContentHelper contentHelper, InvariantHashSet installedMods, IEnumerable <IToken> modTokens, IReflectionHelper reflection) { this.InstalledMods = installedMods; this.GlobalContext = new GenericTokenContext(this.IsModInstalled); this.Reflection = reflection; foreach (IToken modToken in modTokens) { this.GlobalContext.Save(modToken); } foreach (IValueProvider valueProvider in this.GetGlobalValueProviders(contentHelper, installedMods)) { this.GlobalContext.Save(new Token(valueProvider)); } }