This project is read-only.

Build your own fluent interface with Flit

By now, you'll hopefully be familiar with the samples. This page will focus on what you have to do in order run a Flit template in your own project. You might also need to know about the source file syntax or the T4 templates themselves. So let's say you've already got a C# project (new or old) that you want to add a fluent interface to. The files mentioned below can be found in the Flit.Samples project.
  1. Create a source file: foo.txt, and give it a sample content of digraph g{foo bar foo->bar bar->bar} .
  2. Copy over FluentStateBase (and change its namespace if you like). This provides basic functionality to each fluent state class.
  3. Copy over FlitGen.ttinclude.
  4. Add the folder that contains Flit.dll and Irony.dll to your project's reference path, as outlined here.
  5. Create a file called Add in the contents from, say, and change the parameters appropriately (the source file is now foo.txt, for example). Save this file to run the template.
  6. You should now have some boilerplate code generated in foo.g.cs. Read it, and see if it's what you'd expect based on the source file.
  7. Add your own hooks in to consume the calls made to your Fluent API, as outlined here.

Make it your own

At this point, you might want to substitute "foo" with your own domain. Replace the contents of the source txt file, and add labels so that classes and methods can have proper names.

Working in a team

If you're adding Flit to a project that's shared amongst team members, you'll want to add Flit.dll and Irony.dll into source control so that everyone can access them. Be aware that you should never need to release these dlls with your code, the generated file and FluentStateBase contain all of your runtime dependencies. We recommend keeping Flit.dll and Irony.dll in the same place you'd keep NUnit.dll or any other non-released development dependencies or tools.
Everyone in the team will have to individually set up their project's reference path, since the csproj.user file is typically not under source control.

Last edited Oct 18, 2009 at 10:14 PM by robfe, version 4


No comments yet.