|
namespace MongoDBDemoAsync
{
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using MongoDB.Driver;
public class DemoManager
{
#region Constants and Fields
private readonly IMongoCollection<ClubMember> collection;
private readonly Dictionary<int, Tuple<IDemo, string>> DemoDictionary;
#endregion
#region Constructors and Destructors
public DemoManager(IMongoCollection<ClubMember> collection)
{
this.collection = collection;
DemoDictionary = new Dictionary<int, Tuple<IDemo,string>>() {
{ 1,Tuple.Create<IDemo,string>(new AggregationDemo(),"Aggregation Demo") },
{ 2,Tuple.Create<IDemo,string>(new GridFSDemo(),"GridFS Demo") },
{ 3,Tuple.Create<IDemo,string>(new LinqDemo(),"Linq Demo") },
{ 4,Tuple.Create<IDemo,string>(new MapreduceDemo(),"Map Reduce Demo") }
};
}
#endregion
#region Public Methods and Operators
public async Task<bool> PromptNextDemoAsync()
{
Console.WriteLine("Menu");
foreach (KeyValuePair<int,Tuple<IDemo, string>> entry in DemoDictionary)
{
Console.WriteLine($"({entry.Key}) {entry.Value.Item2} ");
}
Console.WriteLine($"({DemoDictionary.Count+1}) Exit ");
int choice= ConsoleHelper.GetNumberFromUser("Enter Menu choice",1,DemoDictionary.Count+1);
if (choice != DemoDictionary.Count + 1)
{
await DemoDictionary[choice].Item1.RunDemoAsync(collection);
return true;
}
return false;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.