public void Run( )
{
#if !(XBOX || XBOX360 || SILVERLIGHT)
AxiomSortedCollection<string, DemoItem> demoList = new AxiomSortedCollection<string, DemoItem>();
#endif
try
{
#if !(XBOX || XBOX360 || SILVERLIGHT)
if (_configure())
{
Assembly demos = Assembly.LoadFrom("Axiom.Demos.dll");
Type[] demoTypes = demos.GetTypes();
Type techDemo = demos.GetType("Axiom.Demos.TechDemo");
foreach (Type demoType in demoTypes)
{
if (demoType.IsSubclassOf(techDemo))
{
demoList.Add(demoType.Name, new DemoItem(demoType.Name, demoType));
}
}
{
Type demoType;
int i = 1;
foreach (KeyValuePair<string, DemoItem> typeName in demoList)
{
Console.WriteLine("{0}) {1}", i++, typeName.Key);
}
Console.WriteLine("Enter the number of the demo that you want to run and press enter.");
while (true)
{
string line = Console.ReadLine();
int number = -1;
if (line != string.Empty)
{
number = int.Parse(line.Trim());
}
if (number < 1 || number > demoList.Count)
Console.WriteLine("The number of the demo game must be between 1 and {0}, the number of demos games available.", demoList.Count);
else
{
demoType = demoList.Values[number - 1].Demo;
break;
}
}
if (demoType != null)
{
using (TechDemo demo = (TechDemo)Activator.CreateInstance(demoType))
{
demo.SetupResources();
demo.Start();//show and start rendering
}//dispose of it when done
}
}
}
#else
using ( TechDemo demo = (TechDemo)(new Axiom.Demos.SkyPlane()))
{
demo.Start();//show and start rendering
}//dispose of it when done
#endif
}
catch ( Exception caughtException )
{
LogManager.Instance.Write( BuildExceptionString( caughtException ) );
}
}