-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvmform.template.xml
97 lines (80 loc) · 2.91 KB
/
vmform.template.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?xml version="1.0" encoding="utf-8"?>
<CodeTemplates version="3.0">
<CodeTemplate version="2.0">
<Header>
<_Group>C#</_Group>
<Version />
<MimeType>text/x-csharp</MimeType>
<Shortcut>vmform</Shortcut>
<_Description>Adds a vm with fluent validation stubs</_Description>
<TemplateType>Unknown</TemplateType>
</Header>
<Variables>
<Variable name="Name">
<Default>MyForm</Default>
</Variable>
</Variables>
<Code><![CDATA[public class $Name$ : ViewModelBase<$Name$>
{
//using System;
//using System.Reactive;
//using System.Reactive.Linq;
//using System.Runtime.Serialization;
//using System.Threading.Tasks;
//using EightBot.BigBang.Extensions;
//using EightBot.BigBang.ViewModel;
//using FluentValidation;
//using ReactiveUI;
//using Splat;
public override string Title => string.Empty;
readonly $Name$Validator _validator = new $Name$Validator();
public override AbstractValidator<$Name$> Validator => _validator;
public $Name$() {}
protected override void Initialize()
{
base.Initialize();
}
ReactiveCommand<Unit> _initializeData;
[DataMember]
public ReactiveCommand<Unit> InitializeData
{
get => _initializeData;
private set => this.RaiseAndSetIfChanged(ref _initializeData, value);
}
ReactiveCommand<UserError> _displayErrorInformation;
public ReactiveCommand<UserError> DisplayErrorInformation
{
get => _displayErrorInformation;
private set => this.RaiseAndSetIfChanged(ref _displayErrorInformation, value);
}
protected override void RegisterObservables()
{
InitializeData =
ReactiveCommand
.CreateAsyncTask(_ => {
return System.Threading.Tasks.Task.FromResult(Unit.Default);
})
.DisposeWith(ViewModelBindings);
/* Navigation Commands *****/
/* Validation *****/
DisplayErrorInformation = ReactiveCommand.CreateAsyncTask(errorInfo => Task.FromResult(errorInfo as UserError)).DisposeWith(ViewModelBindings);
// var validationTriggers =
// Observable.
// Merge(this.WhenAnyValue(x => x.Username).Select(_ => Unit.Default),
// this.WhenAnyValue(x => x.Password).Select(_ => Unit.Default));
// this.RegisterValidation(validationTriggers)
// .DisposeWith(ViewModelBindings);
/* Observables *****/
}
// TODO: either remove this or move this into its own file!
public class $Name$Validator : AbstractValidator<ViewModels.$Name$>
{
public $Name$Validator()
{
//RuleFor(auth => auth.UserName).NotEmpty().Length(4, 20);
//RuleFor(auth => auth.Password).NotEmpty().Length(4, 200);
}
}
}]]></Code>
</CodeTemplate>
</CodeTemplates>