Example #1
0
        public void OperationImportsViewModel_PageEntering(object sender, EventArgs args)
        {
            if (sender is OperationImportsViewModel operationImportsViewModel)
            {
                if (this.ProcessedEndpointForOperationImports != ConfigODataEndpointViewModel.Endpoint)
                {
                    if (ConfigODataEndpointViewModel.EdmxVersion != Constants.EdmxVersion4)
                    {
                        operationImportsViewModel.View.IsEnabled          = false;
                        operationImportsViewModel.IsSupportedODataVersion = false;
                        return;
                    }

                    var model      = EdmHelper.GetEdmModelFromFile(ConfigODataEndpointViewModel.MetadataTempPath);
                    var operations = EdmHelper.GetOperationImports(model);
                    OperationImportsViewModel.LoadOperationImports(operations, new HashSet <string>(SchemaTypesViewModel.ExcludedSchemaTypeNames), SchemaTypesViewModel.SchemaTypeModelMap);

                    if (Context.IsUpdating)
                    {
                        operationImportsViewModel.ExcludeOperationImports(this._serviceConfig?.ExcludedOperationImports ?? Enumerable.Empty <string>());
                    }
                }

                this.ProcessedEndpointForOperationImports = ConfigODataEndpointViewModel.Endpoint;
            }
        }
        public void LoadOperationImports_ShouldSetOperationImportsWithoutDuplicatesAndSelectAll()
        {
            using (var objectSelection = new OperationImportsViewModel())
            {
                objectSelection.OperationImports = new List <OperationImportModel>()
                {
                    new OperationImportModel()
                    {
                        Name = "Func1", IsSelected = false
                    },
                    new OperationImportModel()
                    {
                        Name = "Func2", IsSelected = true
                    },
                    new OperationImportModel()
                    {
                        Name = "Func3", IsSelected = false
                    }
                };

                var container  = new EdmEntityContainer("Test", "Default");
                var listToLoad = new List <IEdmOperationImport>()
                {
                    new EdmActionImport(container, "Update", new EdmAction("Test", "Update", null)),
                    new EdmFunctionImport(container, "GetTotal",
                                          new EdmFunction("Test", "GetTotal",
                                                          new EdmTypeReferenceForTest(
                                                              new EdmTypeDefinition("Test", "TypeDef", EdmPrimitiveTypeKind.Int32), false))),
                    new EdmActionImport(container, "Update",
                                        new EdmAction("Test", "Update",
                                                      new EdmTypeReferenceForTest(
                                                          new EdmTypeDefinition("Test", "TypeDef", EdmPrimitiveTypeKind.String), false)))
                };

                objectSelection.LoadOperationImports(listToLoad, new HashSet <string>(), new Dictionary <string, SchemaTypeModel>());

                objectSelection.OperationImports.ShouldBeEquivalentTo(new List <OperationImportModel>()
                {
                    new OperationImportModel
                    {
                        ReturnType       = "Test.TypeDef",
                        ParametersString = "()",
                        Name             = "GetTotal",
                        IsSelected       = true
                    },
                    new OperationImportModel
                    {
                        ReturnType       = "void",
                        ParametersString = "()",
                        Name             = "Update",
                        IsSelected       = true
                    }
                });
            }
        }
        public void LoadOperationImports_ShouldSetOperationImportsWithoutDuplicatesAndSelectAll()
        {
            var objectSelection = new OperationImportsViewModel();

            objectSelection.OperationImports = new List <OperationImportModel>()
            {
                new OperationImportModel()
                {
                    Name = "Func1", IsSelected = false
                },
                new OperationImportModel()
                {
                    Name = "Func2", IsSelected = true
                },
                new OperationImportModel()
                {
                    Name = "Func3", IsSelected = false
                }
            };

            var container  = new EdmEntityContainer("Test", "Default");
            var listToLoad = new List <IEdmOperationImport>()
            {
                new EdmActionImport(container, "Update", new EdmAction("Test", "Update", null)),
                new EdmFunctionImport(container, "GetTotal",
                                      new EdmFunction("Test", "GetTotal",
                                                      new EdmTypeReferenceForTest(
                                                          new EdmTypeDefinition("Test", "TypeDef", EdmPrimitiveTypeKind.Int32), false))),
                new EdmActionImport(container, "Update",
                                    new EdmAction("Test", "Update",
                                                  new EdmTypeReferenceForTest(
                                                      new EdmTypeDefinition("Test", "TypeDef", EdmPrimitiveTypeKind.String), false)))
            };

            objectSelection.LoadOperationImports(listToLoad);

            objectSelection.OperationImports.ShouldBeEquivalentTo(new List <OperationImportModel>()
            {
                new OperationImportModel()
                {
                    Name = "GetTotal", IsSelected = true
                },
                new OperationImportModel()
                {
                    Name = "Update", IsSelected = true
                }
            });
        }
        public void ObjectSelectionViewModel_PageEntering(object sender, EventArgs args)
        {
            if (sender is OperationImportsViewModel objectSelectionViewModel)
            {
                if (ConfigODataEndpointViewModel.EdmxVersion != Constants.EdmxVersion4)
                {
                    objectSelectionViewModel.View.IsEnabled          = false;
                    objectSelectionViewModel.IsSupportedODataVersion = false;
                    return;
                }
                var model      = EdmHelper.GetEdmModelFromFile(ConfigODataEndpointViewModel.MetadataTempPath);
                var operations = EdmHelper.GetOperationImports(model);
                OperationImportsViewModel.LoadOperationImports(operations);

                if (Context.IsUpdating)
                {
                    var serviceConfig = Context.GetExtendedDesignerData <ServiceConfigurationV4>();
                    objectSelectionViewModel.ExcludeOperationImports(serviceConfig?.ExcludedOperationImports ?? Enumerable.Empty <string>());
                }
            }
        }