/// <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> /// 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, 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; } } }; toLoad.Add(operationImportModel); alreadyAdded.Add(operation.Name); } } OperationImports = toLoad.OrderBy(o => o.Name).ToList(); }