5 Using WetPancake
Craig Oates edited this page 4 years ago

Although there are slight variations, you will use Wet Pancake (W.P.) as a two-step procedure. They are:

  1. Call a function from the Pancake module, within the WetPancake name-space. You can find the module in "ProductServices.fs" (if you want to look at the source code).
  2. Tell the function to run either synchronously or asynchronously and await the results.

It is worth pointing out, most functions are asynchronous. If you are unsure about the function being asynchronous or not, use Visual Studio's intellisense. All public functions within W.P. contain XML comments (I.E. intellisense comments). If you are having trouble with intellisense, you can read the source code to see what the it should say. Having said that, all public functions should include Async at the end of its name if they are asynchronous. The link for the (public facing) source code is available using the following link:

To help explain the typical flow of W.P., please consider the diagram below.

wetpancake typical flow

Within W.P., you will find eight functions, which are:

  1. CleanResultAsync
  2. TextInFileIsValidAsync
  3. RequestRandomTextAsync
  4. RequestTextAsync
  5. RequestTextFromFileAsync
  6. RequestAllTemplateFiles
  7. RequestCleanTextAsync
  8. RequestCleanTextFromFileAsync

Instead of repeating the code here, I recommend you open up "ProduceServices.fs". As stated above, all the functions have XML comments to help explain what each function does. If you prefer, I have prepared a A.P.I. overview for these functions for you to look at. Links to the source code and A.P.I. overview are as follows:

To help you get a sense of how these functions look in the wild, I have provided some examples in the Snippets section. If they are not enough, you can take a look at how I have used W.P. in the WetPancakeCLI project. The links for both are as follows:

The TextFiles Folder

When you add WetPancake to your project, you will notice it also adds a folder call "TextFiles". If you look in it, you will notice it contains four plain-text (.txt) files. Their names are:

  1. console-waterworks-announcement.txt
  2. desktop-clock-info.txt
  3. test-post.txt
  4. word-generator.txt

There is nothing special about any of them. The are just blog posts from my own site. The reason they are here is because the were lying around on my hard-drive. They, also, take the burden off you to create your own. Having said that, W.P. allows you to use your own if you want to. See "Using Your Own Text Files" below for more information.

When W.P. generates text, it will use these .txt files as its starting point. As stated in other places, W.P. creates a Markov Chain when it generates its results. If you are unsure how or what a Markov Chain is, I recommend you use the following link:

Using Your Own Text Files

There are two ways you can use your own .txt files with .W.P. The first way is to let your end-user select it; and, the second way is to add your own .txt files to the TextFiles folder and then compile your project. The former gives the end-user more control over the results your program will produce; and, the latter offers better ease-of-use. Essentially, your decision to use .txt files beyond the ones provided is up to you so I have nothing to add here. If you do decide to offer your end-user this functionality, you can do so by using the following functions:

  • RequestTextFromFileAsync
  • RequestCleanTextFromFileAsync

I have written more about this topic in the "As Source Code" section. I recommend you read what I have said there to help you get a better grasp of the limitations of using your own .txt files. On top of that, I have provided some examples in the Snippets section to show you how you can use these features in your project. Last of all, you can have a look at how I have incorporated these features in WetPancakeCLI. The links for all that is as follows: