public TypeSelectorViewModel(IResourceServiceModel resourceServiceModel, ResourceTreeItemViewModel resource) { _resourceServiceModel = resourceServiceModel; var rootType = _resourceServiceModel.TypeTree; var constraint = new[] { rootType.Name }; // Extract children constraint if (resource != null) { var resourceType = _resourceServiceModel.TypeTree.DerivedTypes .Flatten(t => t.DerivedTypes).First(t => t.Name == resource.Resource.TypeName); constraint = resourceType.References.First(r => r.Name == "Children").SupportedTypes; } var matches = FilterTypes(rootType, constraint); // If there is a single, abstract root node, we can skip it if (matches.Count == 1 && !matches[0].Creatable) { matches = matches[0].DerivedTypes; } TypeTree = matches.Select(type => new ResourceTypeViewModel(type)); CreateCmd = new AsyncCommand(Create, CanCreate); CancelCmd = new RelayCommand(Cancel, CanCancel); }
public RemoveResourceViewModel(IResourceServiceModel resourceServiceModel, ResourceViewModel resource) { _resourceServiceModel = resourceServiceModel; ResourceToRemove = resource; RemoveCmd = new AsyncCommand(Remove, CanRemove, true); CancelCmd = new RelayCommand(Cancel, CanCancel); }
public SelectTargetDialogViewModel(ResourceReferenceViewModel reference, IResourceServiceModel resourceServiceModel) { _resourceServiceModel = resourceServiceModel; Reference = reference; SelectCmd = new RelayCommand(Select, CanSelect); CancelCmd = new RelayCommand(Cancel); }