public override async Task OnPageEnteringAsync(WizardEnteringArgs args) { await base.OnPageEnteringAsync(args); View = new OperationImports() { DataContext = this }; PageEntering?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Loads operation imports except the ones that require a type that is excluded. /// </summary> /// <param name="operationImports">A list of all the operation imports.</param> /// <param name="excludedSchemaTypes">A collection of schema types that will be excluded from generated code.</param> /// <param name="schemaTypeModels">A dictionary of schema type and the associated schematypemodel.</param> public void LoadOperationImports(IEnumerable <IEdmOperationImport> operationImports, ICollection <string> excludedSchemaTypes, IDictionary <string, SchemaTypeModel> schemaTypeModels) { var toLoad = new List <OperationImportModel>(); var alreadyAdded = new HashSet <string>(); foreach (var operation in operationImports) { if (!alreadyAdded.Contains(operation.Name)) { var operationImportModel = new OperationImportModel() { Name = operation.Name, ReturnType = operation.Operation?.ReturnType?.FullName() ?? "void", ParametersString = EdmHelper.GetParametersString(operation.Operation?.Parameters), IsSelected = IsOperationImportIncluded(operation, excludedSchemaTypes) }; operationImportModel.PropertyChanged += (s, args) => { if (s is OperationImportModel currentOperationImportModel) { IEnumerable <IEdmOperationParameter> parameters = operation.Operation.Parameters; foreach (var parameter in parameters) { if (schemaTypeModels.TryGetValue(parameter.Type.FullName(), out SchemaTypeModel model) && !model.IsSelected) { model.IsSelected = currentOperationImportModel.IsSelected; } } string returnTypeName = operation.Operation.ReturnType?.FullName(); if (returnTypeName != null && schemaTypeModels.TryGetValue(returnTypeName, out SchemaTypeModel schemaTypeModel) && !schemaTypeModel.IsSelected) { schemaTypeModel.IsSelected = currentOperationImportModel.IsSelected; } } if (this.View is OperationImports view) { view.SelectedOperationImportsCount.Text = OperationImports.Count(x => x.IsSelected).ToString(CultureInfo.InvariantCulture); } }; toLoad.Add(operationImportModel); alreadyAdded.Add(operation.Name); } } OperationImports = toLoad.OrderBy(o => o.Name).ToList(); _operationImportsCount = OperationImports.Count(); }
/// <summary> /// Executed when entering the page for selecting operation imports. /// It fires PageEntering event which ensures all types are loaded on the UI. /// It also ensures all related entities are computed and cached. /// </summary> /// <param name="args">Event arguments being passed to the method.</param> public override async Task OnPageEnteringAsync(WizardEnteringArgs args) { this.IsEntered = true; await base.OnPageEnteringAsync(args).ConfigureAwait(false); this.View = new OperationImports { DataContext = this }; this.PageEntering?.Invoke(this, EventArgs.Empty); if (this.View is OperationImports view) { view.SelectedOperationImportsCount.Text = OperationImports.Count(x => x.IsSelected).ToString(CultureInfo.InvariantCulture); } }