private void SavePlaceable(object sender, GameObjectSaveEventArgs e) { using (PlaceableRepository repo = new PlaceableRepository()) { repo.Upsert(e.ActivePlaceable); } }
public void UpsertInDatabase(GameObjectBase gameObject, string connectionString = "") { if (gameObject.GameObjectType == GameObjectTypeEnum.Area) { using (AreaRepository repo = new AreaRepository(connectionString)) { repo.Upsert(gameObject as Area); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Conversation) { using (ConversationRepository repo = new ConversationRepository(connectionString)) { repo.Upsert(gameObject as Conversation); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Creature) { using (CreatureRepository repo = new CreatureRepository(connectionString)) { repo.Upsert(gameObject as Creature); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Item) { using (ItemRepository repo = new ItemRepository(connectionString)) { repo.Upsert(gameObject as Item); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Placeable) { using (PlaceableRepository repo = new PlaceableRepository(connectionString)) { repo.Upsert(gameObject as Placeable); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Script) { using (ScriptRepository repo = new ScriptRepository(connectionString)) { repo.Upsert(gameObject as Script); } } else if (gameObject.GameObjectType == GameObjectTypeEnum.Tileset) { using (TilesetRepository repo = new TilesetRepository(connectionString)) { repo.Upsert(gameObject as Tileset); } } else { throw new NotSupportedException(); } }