Skip to content

Instantly share code, notes, and snippets.

🤔
Probably thinking about code

Matt Eland IntegerMan

🤔
Probably thinking about code
Block or report user

Report or block IntegerMan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PastaContext.cs
public class PastaContext
{
// Initialization not included - would happen at the constructor level as a pass through
public KitchenSupplies Supplies {get;}
public DateTime TimeOfDay {get;}
public IngerdientPriceData PricingData {get;}
}
View PastaMaker2.cs
public PastaMeal BuildPastaMeal(IEnumerable<Guest> guests,
KitchenSupplies inventory,
DateTime timeOfDay,
IngredientPriceData pricingData)
{
var dinner = new PastaMeal();
// Add a quanity of pasta per guest based on time of day and kitchen supply quantities
// This algorithm will try to prefer cheaper types of pasta
View PastaMaker.cs
public PastaMeal BuildPastaMeal(IEnumerable<Guest> guests,
KitchenSupplies inventory,
DateTime timeOfDay)
{
var dinner = new PastaMeal();
// Add a quanity of pasta per guest based on time of day and kitchen supply quantities
return dinner;
}
View Program.fs
open System
open Elmish.WPF
open MattEland.DailyScrum.WinElmish.Views
/// This is the main data model for our application
type Model = {
ClickCount: int
Message: string
}
View program.bindings.fs
/// Elmish uses this to provide the data context for your view based on a model
let bindings () : Binding<Model, MessageType> list = [
// One-Way Bindings
"ClickCount" |> Binding.oneWay (fun m -> m.ClickCount)
"Message" |> Binding.oneWay (fun m -> m.Message)
// Commands
"ClickCommand" |> Binding.cmd ButtonClicked
"ResetCommand" |> Binding.cmd Reset
]
View Program.Reducer.fs
/// This is the Reducer Elmish.WPF calls to generate a new model based on a message and an old model
let update (msg: MessageType) (model: Model) : Model =
match msg with
| ButtonClicked -> { model with ClickCount = model.ClickCount + 1}
| Reset -> init()
View Program.Reducer.fs
/// This is the Reducer Elmish.WPF calls to generate a new model based on a message and an old model
let update (msg: MessageType) (model: Model) : Model =
match msg with
| ButtonClicked -> { model with ClickCount = model.ClickCount + 1}
| Reset -> init()
View Program.MessageType.fs
/// This is a discriminated union of the available messages from the user interface
type MessageType =
| ButtonClicked
| Reset
View Program.init.fs
/// This is the main data model for our application
type Model = {
ClickCount: int
Message: string
}
/// This is used to define the initial state of our application
let init() = {
ClickCount = 0
Message = "Hello Elmish.WPF"
View Program.EntryPoint.fs
/// This is the application's entry point. It hands things off to Elmish.WPF
[<EntryPoint; STAThread>]
let main _ =
Program.mkSimpleWpf init update bindings
|> Program.runWindow (MainWindow())
You can’t perform that action at this time.