Click or drag to resize
Page 12: Send Local Changes to the Provider

Now that we have types for everything, changes can be made much more cleanly:

C#
AsyncPump.Run(
    async () =>
    {
        using (var client = await ConnectAsync("localhost", 9000))
        using (var consumer = await Consumer<SapphireRoot>.CreateAsync(client))
        {
            var fader = consumer.Root.Sapphire.Sources.Fpgm1.Fader;
            fader.DBValue.Value = -67.0;
            fader.Position.Value = 128;
            await consumer.SendAsync();
        }
    });
Note Note

While many simple typos or other programmer mistakes would lead to exceptions with the dynamic interface (see Page 7: Send Local Changes to the Provider), here most of them will be caught by the compiler. Moreover, since we now have IntelliSense for our database, fewer typos are made in the first place. Of course, whether the expectations expressed in the types match with what a particular provider offers is still verified at runtime, but it is done in one place (ConsumerTRootCreateAsync) and thus client code can handle mismatches with a single catch block.

Proceed to Page 13: Unbounded Nodes.