public IList<string> GetCollections(string server, string database, string port)
{
_db = new Mongo(string.Format("Server={0}:{1}", server, port));
try
{
_db.Connect();
}
catch (SocketException ex)
{
throw new UnknownServerException(string.Format("Unknown server: {0}:{1}", server, port), ex);
}
IList<String> collectionNames = _db[database].GetCollectionNames();
var filteredCollections = new List<string>();
var hiddenCollectionCriteria = new string[] {"cubicle", "tmp.", ".$", "system.indexes"};
foreach (string collectionName in collectionNames)
{
if (!hiddenCollectionCriteria.Any(criteria => collectionName.Contains(criteria)))
{
int periodIndex = collectionName.IndexOf(".");
string collection = collectionName;
if (periodIndex >= 0 && periodIndex != (collectionName.Length - 1))
collection = collectionName.Substring(collectionName.IndexOf(".") + 1);
filteredCollections.Add(collection);
}
}
return filteredCollections;
}