-
Notifications
You must be signed in to change notification settings - Fork 24
Labs
Rxx labs are built on an open source project called Labs Framework. You can use this framework to create your own labs against Rxx or you can download Rxx's source code and modify our labs directly, which is described later in this document.
Note: Labs Framework must be installed; otherwise, the Rxx.Labs project cannot be loaded. You can safely remove this project from the solution if you don't want to install it.
Rxx labs illustrate some of the various uses of Rxx, in some cases allowing you to provide input and to control their behavior. Features are accessible in one of the following categories:
-
Reactive: Provides LINQ extension methods for
IObservable<T>
. -
Interactive: Provides LINQ extension methods for
IEnumerable<T>
. - Parsers: Provides LINQ extension methods for parsing sequences. Includes Reactive and Interactive subcategories.
Download the latest version of Rxx Labs. There are no runtime requirements other than the .NET Framework 4.5.1.
- Right-mouse click the RxxLabs.exe program and select Run as Administrator to begin.
- The Reactive WebClient and WCF labs will not function properly unless you run the program with admin privileges.
- Choose a lab from the drop-down list at the top of the application.
- Follow the on-screen instructions.
- Download the latest Rxx source code.
- Open the Rxx solution in Visual Studio.
- Right-mouse click:
- the Reactive folder, if you want to experiment with
IObservable<T>
. - the Interactive folder, if you want to experiment with
IEnumerable<T>
.
- the Reactive folder, if you want to experiment with
- Select Add > New Item.... The Add New Item dialog opens.
- Expand the Visual C# node and select Labs.
- Labs Framework must be installed. You may need to restart Visual Studio after installing if you don't see the Labs node.
- In the right pane, select Console Lab and click Add.
- Begin coding your lab in the
Main
method. You can use the following examples for guidance. - You may also choose to add a WPF Lab instead of a Console Lab. See the Labs Framework documentation for details.
using System;
using System.ComponentModel;
using System.Reactive.Linq;
using Rxx.Labs.Properties;
namespace Rxx.Labs.Reactive
{
[DisplayName("Your Lab Name")]
[Description("Your lab's description.")]
public sealed class [YourLabName]Lab : BaseConsoleLab
{
protected override void Main()
{
// Prompt the user for input.
int take;
while (!int.TryParse(UserInput("How many items? "), out take)) { }
// Show instructions to the user.
TraceLine(Instructions.PressAnyKeyToCancel);
// Initialize lab state and observables.
var xs = Observable.Interval(TimeSpan.FromSeconds(1)).Take(take);
// Subscribe the base ConsoleOutput method (without invoking it).
using (xs.Subscribe(ConsoleOutput))
{
// Optionally allow the user to cancel the subscription
// by pressing a key.
WaitForKey();
}
// Alternatively, use the ForEach method instead of Subscribe to block
// until the observable completes.
xs.ForEach(ConsoleOutput);
}
}
}
using System.ComponentModel;
using System.Linq;
using Rxx.Labs.Properties;
namespace Rxx.Labs.Interactive
{
[DisplayName("Your Lab Name")]
[Description("Your lab's description.")]
public sealed class [YourLabName]Lab : BaseConsoleLab
{
protected override void Main()
{
// Prompt the user for input.
int count;
while (!int.TryParse(UserInput("How many items? "), out count)) { }
// Show instructions to the user.
TraceLine(Instructions.WaitForCompletion);
// Initialize lab state and enumerables.
var xs = Enumerable.Range(1, count);
// Run the sequence, sending output to the base
// ConsoleOutput method (without invoking it).
xs.ForEach(ConsoleOutput);
}
}
}
Development Requirements
- Visual Studio 2015 RC
-
Code Contracts
- VS 2015 release is not yet available at the time of writing.
Additional Tools
(No installation required)
- Code Analysis (VS 2015)
- StyleCop (NuGet Package)