예제 #1
0
 /// <summary>
 /// Returns a list of all objects in the database of a specified resource type.
 /// </summary>
 /// <param name="resourceType"></param>
 /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
 /// <returns></returns>
 public List<GameObjectBase> GetAllFromDatabase(GameObjectTypeEnum resourceType, string connectionString = "")
 {
     if (resourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }