/// <summary> /// Creates an appropriate ViewModel for a type of component parameter, and the parameter is taken as the model. /// Throws an exception if can't create the ViewModel. /// </summary> /// <param name="component">Quest Component that will be a model for a ViewModel instance.</param> /// <returns></returns> public static AbstractComponentViewModel CreateComponentViewModel(AbstractQuestComponent component) { if (component is null) { throw new ArgumentNullException(nameof(component)); } AbstractComponentViewModel componentViewModel = null; switch (component.GetType().Name) { case nameof(DescriptionComponent): var descriptionComponent = component as DescriptionComponent; var descriptionViewModel = new DescriptionComponentViewModel(descriptionComponent); componentViewModel = descriptionViewModel; break; case nameof(ProgressComponent): var progressComponent = component as ProgressComponent; var progressViewModel = new ProgressComponentViewModel(progressComponent); componentViewModel = progressViewModel; break; default: throw new ArgumentException($"Can't create ViewModel for {component.GetType().FullName}."); } return(componentViewModel); }
void SetProgressComponentBindings(ProgressComponentViewModel progressViewModel, DetailQuestView detailQuestView) { if (progressViewModel is null) { throw new ArgumentNullException(nameof(progressViewModel)); } if (detailQuestView is null) { throw new ArgumentNullException(nameof(detailQuestView)); } }