Visit http://labs.codeplex.com for documentation, discussions, bug tracking and the complete source code. NOTE: If you're using Visual Studio 2012, then install Labs Framework 2.0 instead:http://labs.codeplex.com/releases/view/94117 Labs Framework enables you to create and manage experiments in C#, Visual Basic and F# during everyday software development using .NET 4.0/4.5.1, Silverlight 5 or Windows Phone 8. Labs Framework includes Visual Studio 2013 templates for creating lab application projects in multiple languages and platforms. It also provides a cross-platform console GUI and an API for acquiring user input and tracing output. Labs can be written once and linked into multiple projects to be executed on multiple platforms, such as WPF, Silverlight, Windows Phone and the command-line. Labs targeting WPF, Silverlight and Windows Phone applications can also have custom XAML interfaces that are linked between projects. Lab projects build executables that can be distributed as hands-on labs to help other developers (customers or teammates) learn how to use your libraries properly on multiple platforms. Here's an example WPF labs application showing a console lab with multiple experiments:
The console lab shown in the WPF labs application above can be added to any lab project, unmodified. It can target any of the supported platforms: WPF, Silverlight 5, Windows Phone 8 and desktop console applications. The lab's cross-platform source code is shown below in its entirety. C# Edit|Remove csharpusing System;namespace MyLabs{ public sealed class MathLab : BaseConsoleLab { protected override void Main() { RunExperiments(); } public void Add() { var n = UserInputNumbers(); TraceLine("{0} + {1} = {2}", n.Item1, n.Item2, n.Item1 + n.Item2); } public void Multiply() { var n = UserInputNumbers(); TraceLine("{0} * {1} = {2}", n.Item1, n.Item2, n.Item1 * n.Item2); } public void ExclusiveOr() { var n = UserInputNumbers(); TraceLine("{0} ^ {1} = {2}", n.Item1, n.Item2, n.Item1 ^ n.Item2); } private Tuple<int, int> UserInputNumbers() { return Tuple.Create( UserInputNumber("Enter the first number> "), UserInputNumber("Enter the second number> ")); } private int UserInputNumber(string message) { int value; do { if (int.TryParse(UserInput(message), out value)) { return value; } else { TraceError("Unrecognized value. Please try again."); } } while (true); } }} using System; namespace MyLabs { public sealed class MathLab : BaseConsoleLab { protected override void Main() { RunExperiments(); } public void Add() { var n = UserInputNumbers(); TraceLine("{0} + {1} = {2}", n.Item1, n.Item2, n.Item1 + n.Item2); } public void Multiply() { var n = UserInputNumbers(); TraceLine("{0} * {1} = {2}", n.Item1, n.Item2, n.Item1 * n.Item2); } public void ExclusiveOr() { var n = UserInputNumbers(); TraceLine("{0} ^ {1} = {2}", n.Item1, n.Item2, n.Item1 ^ n.Item2); } private Tuple<int, int> UserInputNumbers() { return Tuple.Create( UserInputNumber("Enter the first number> "), UserInputNumber("Enter the second number> ")); } private int UserInputNumber(string message) { int value; do { if (int.TryParse(UserInput(message), out value)) { return value; } else { TraceError("Unrecognized value. Please try again."); } } while (true); } } } |