This project has moved and is read-only. For the latest updates, please go here.

Rxx Hands-on Labs

Overview

The hands-on labs program is an application that illustrates the various uses of the Rxx APIs, in some cases allowing you to provide input and to control their behavior. Each Rxx API is accessible in one of the following categories:
  • Reactive: Provides LINQ extension methods for IObservable<T>; a.k.a., Reactive Extensions (Rx).
  • Interactive: Provides LINQ extension methods for IEnumerable<T>; a.k.a., Interactive Extensions (Ix).
  • Parsers: Provides LINQ extension methods for parsing sequences. Includes Reactive and Interactive subcategories.
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.

How to use the Rxx labs

Download the latest version of Rxx Labs for your desired platform and then follow the appropriate procedure below.

To run the desktop 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.

To launch the Silverlight labs

  1. Double-click the .html file included in the download.
  2. You may be prompted to install the required version of Silverlight.
  3. Choose a lab from the drop-down list at the top of the application.
  4. Follow the on-screen instructions.

To launch the Windows Phone labs

You must deploy to either a real device or the emulator software as follows:
  1. Run the Deploy.bat script included in the download to get started.
  2. If you've already registered a real device then you may deploy to that device; otherwise, choose the Windows Phone 7 Emulator from the drop-down list.
  3. Click the Deploy button.
  4. Wait for the deployment status to show completion. The emulator will start during this time, but it won't be ready until the status is updated in the deployment window.
  5. After the deployment has completed you may close the deployment application.
  6. In the emulator or a real device, click the arrow to show the list of installed applications and then launch the Rxx Labs application.
  7. You may install Rxx labs for WP7.0 and WP7.1 on the same device. They will run side-by-side.

How to view the Rxx labs source

  1. You can view the source code of individual labs simply by running the labs application.
  2. You can browse the entire Rxx and Rxx Labs source code online: http://rxx.codeplex.com/SourceControl/BrowseLatest
  3. You can also download the full source code. See How To Build the Source Code for details.

How to create new Rxx labs

  1. Read How To Make Contributions first, if you're interested in making contributions.
  2. Download the latest source code: http://rxx.codeplex.com/SourceControl/list/changesets
  3. Read How To Build the Source Code for details on how to configure, open and build the Rxx solution.
    1. If you only want to use the lab project:
      1. Remove all projects from the solution except for the Rxx.Labs project.
      2. Remove the project reference to Rxx and add an assembly reference to Rxx.dll.
  4. Add a new class to the Rxx.Labs project.
    1. 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>.
    2. Select Add > New Item.... The Add New Item dialog opens.
    3. If you do not have the Labs Framework installed, then select either the Code File template or the Class template and click Add. Replace the entire contents of the file with one of the following examples to get started.
    4. Otherwise, if you have already installed the Labs Framework and restarted Visual Studio, then follow this procedure:
      1. Expand the Visual C# node and select Labs.
      2. In the right pane, select Console Lab and click Add. Add New Lab (Click the image for details.)
      3. Begin coding your lab in the Main method. You can use the following examples for guidance.
      4. 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);
        }
    }
}

Last edited Mar 10, 2012 at 8:29 AM by davedev, version 13