Skip to content
Dave Sexton edited this page May 3, 2015 · 7 revisions

Overview

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.

How to use the Rxx labs

Download the latest version of Rxx Labs. There are no runtime requirements other than the .NET Framework 4.5.1.

To run the labs application
  1. Right-mouse click the RxxLabs.exe program and select Run as Administrator to begin.
    1. The Reactive WebClient and WCF labs will not function properly unless you run the program with admin privileges.
  2. Choose a lab from the drop-down list at the top of the application.
  3. Follow the on-screen instructions.

How to Create Labs

  1. Download the latest Rxx source code.
  2. Open the Rxx solution in Visual Studio.
  3. Right-mouse click:
    1. the Reactive folder, if you want to experiment with IObservable<T>.
    2. the Interactive folder, if you want to experiment with IEnumerable<T>.
  4. Select Add > New Item.... The Add New Item dialog opens.
  5. Expand the Visual C# node and select Labs.
    1. Labs Framework must be installed. You may need to restart Visual Studio after installing if you don't see the Labs node.
  6. In the right pane, select Console Lab and click Add.
  7. Begin coding your lab in the Main method. You can use the following examples for guidance.
  8. You may also choose to add a WPF Lab instead of a Console Lab. See the Labs Framework documentation for details.

Reactive Lab Example

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);
        }
    }
}

Interactive Lab Example

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

Additional Tools

(No installation required)

  • Code Analysis (VS 2015)
  • StyleCop (NuGet Package)
Clone this wiki locally