Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created May 19, 2012 21:51
Show Gist options
  • Select an option

  • Save anaisbetts/2732489 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/2732489 to your computer and use it in GitHub Desktop.
Using Mustache to generate C# code
using System;
using ReactiveUI;
using ReactiveUI.Xaml;
using ReactiveUI.Routing;
namespace {{projectName}}.ViewModels
{
{{#interfaces}}
{{definition}}
{{/interfaces}}
{{#interfaces}}
public void {{implClassName}} : ReactiveObject, {{interfaceName}}
{
{{#properties}}
{{#outputProp}}
ObservableAsPropertyHelper<{{type}}> _{{name}};
public {{type}} {{name}} {
get { return _{{name}}; }
}
{{/outputProp}}
{{#readWriteProp}}
{{type}} _{{name}};
public {{type}} {{name}} {
get { return _{{name}}; }
set { this.RaiseAndSetIfChanged(x => x.{{name}}, value); }
}
{{/readWriteProp}}
{{#onceProp}}
{{type}} {{name}} { get; protected set; }
{{/onceProp}}
{{/properties}}
{{#isRoutableViewmodel}}
public IScreen HostScreen { get; protected set; }
public string UrlPathSegment {
get { return "TODO: Implement Me"; }
}
public {{implClassName}}(IScreen hostScreen)
{
HostScreen = hostScreen;
// TODO: Wire up your properties here!
}
{{^isRoutableViewmodel}}
public {{implClassName}}()
{
// TODO: Wire up your properties here!
}
{{/isRoutableViewmodel}}
}
{{/interfaces}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment