Beispiel #1
0
        private static EmployeeVMDescriptor CreateDescriptor(
            ProjectVMDescriptor projectVMDescriptor,
            Action <EmployeeVM, ChangeArgs> handleChangeAction
            )
        {
            return(VMDescriptorBuilder
                   .OfType <EmployeeVMDescriptor>()
                   .For <EmployeeVM>()
                   .WithProperties((d, c) => {
                var b = c.GetPropertyBuilder(x => x.Source);

                d.Name = b.Property.MapsTo(x => x.Name);
                d.Projects = b.Collection
                             .Wraps(x => x.Projects)
                             .With <ProjectVM>(projectVMDescriptor);
                d.SelectedProject = b.Property.Of <ProjectVM>();
            })
                   .WithValidators(b => {
                b.Check(x => x.Name)
                .HasValue(String.Empty);
                b.CheckCollection(x => x.Projects, x => x.Title)
                .IsUnique(string.Empty);
            })
                   .WithViewModelBehaviors(b => {
                b.IsUndoRoot();
                b.AddChangeHandler((vm, changeArgs) => {
                    handleChangeAction(vm, changeArgs);
                });
            })
                   .Build());
        }
Beispiel #2
0
 public EmployeeVM(ProjectVMDescriptor projectVMDescriptor)
     : base(CreateDescriptor(projectVMDescriptor, NoChangeHandling))
 {
 }