public CharacterItemsInitialization(ICharacterManagementContextFactory contextFactory, IItemDefList itemDefList, ILoggerFactory loggerFactory) { if (contextFactory == null) { throw new ArgumentNullException(nameof(contextFactory)); } if (itemDefList == null) { throw new ArgumentNullException(nameof(itemDefList)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } var logger = loggerFactory.GetLogger(GetType()); using (var db = contextFactory.Create()) { //Get items types that have already been registered in the database. var characterItemEntities = db.CharacterItems.ToDictionary(entity => entity.ItemName.ToUpperInvariant()); //Add all items that are defined but not registered in the database to the database. foreach (var itemDef in itemDefList.AllDefinitions) { if (!characterItemEntities.ContainsKey(itemDef.CodeName.ToUpperInvariant())) { db.CharacterItems.Add( new CharacterItemEntity() { ItemName = itemDef.CodeName.ToUpperInvariant() }); logger.Info($"Added item definition '{itemDef.CodeName.ToUpperInvariant()}'"); } } //Save the changes to the database. db.SaveChanges(); } }
internal CreateHumanPlayerCharacterTransaction( CharacterService characterService, ICharacterNameValidator nameValidator, ILoggerFactory loggerFactory, ICharacterManagementContextFactory contextFactory, ISpawnPointProvider spawnPointProvider, ICharacterTemplateSelector characterTemplateSelector, CharacterBuilder characterBuilder, IMainThreadDispatcher dispatcher) { _CharacterService = characterService; _NameValidator = nameValidator ?? throw new ArgumentNullException(nameof(nameValidator)); _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _SpawnPointProvider = spawnPointProvider ?? throw new ArgumentNullException(nameof(spawnPointProvider)); _CharacterTemplateSelector = characterTemplateSelector ?? throw new ArgumentNullException(nameof(characterTemplateSelector)); _CharacterBuilder = characterBuilder ?? throw new ArgumentNullException(nameof(characterBuilder)); _Dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher)); _Log = loggerFactory.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public GetCharacterOwnershipsCountTransaction(ICharacterManagementContextFactory contextFactory, ILoggerFactory loggerFactory) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _Log = loggerFactory?.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public SaveCharacterTransaction(ICharacterManagementContextFactory contextFactory) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); }
internal SetAccountActiveCharacterTransaction(ICharacterManagementContextFactory contextFactory, ILoggerFactory loggerFactory) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _Log = loggerFactory?.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }
internal CheckCharacterExistsTransaction(ILoggerFactory loggerFactory, ICharacterManagementContextFactory contextFactory) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _Log = loggerFactory?.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public GetAccountOwnedCharactersTransaction(ICharacterManagementContextFactory contextFactory, CharacterBuilder characterBuilder, ILoggerFactory loggerFactory) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _CharacterBuilder = characterBuilder ?? throw new ArgumentNullException(nameof(characterBuilder)); _Log = loggerFactory?.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }
public AddCharacterOwnerShipTransaction(ICharacterManagementContextFactory contextFactory, ILoggerFactory loggerFactory, RpConfig rpConfig) { _ContextFactory = contextFactory ?? throw new ArgumentNullException(nameof(contextFactory)); _RpConfig = rpConfig ?? throw new ArgumentNullException(nameof(rpConfig)); _Log = loggerFactory?.GetLogger(GetType()) ?? throw new ArgumentNullException(nameof(loggerFactory)); }