Пример #1
0
        private void Extend_Predefined_ViewItem(PredefinedMap predefinedMap, string mapPropertyName,
                                                bool checkListViewColumns = false)
        {
            using (var module = predefinedMap.Extend()){
                var connectableObservable = TypeMappingService.MappedTypes.Replay();
                connectableObservable.Connect();
                using (var application =
                           DefaultModelMapperModule($"{nameof(Extend_Predefined_PropertyEditorControls)}-{predefinedMap}",
                                                    predefinedMap.Platform(), module).Application){
                    var typeToMap = predefinedMap.TypeToMap();

                    var modelNode = application.Model.GetNodeByPath(MMDetailViewTestItemNodePath);
                    modelNode.GetNode(mapPropertyName).ShouldNotBeNull();
                    if (checkListViewColumns)
                    {
                        modelNode = application.Model.GetNodeByPath(MMListViewTestItemNodePath);
                        modelNode.GetNode(mapPropertyName).ShouldNotBeNull();
                    }

                    var typeInfo = XafTypesInfo.Instance.FindTypeInfo(typeof(IModelModelMap)).Descendants
                                   .FirstOrDefault(info => info.Name.EndsWith(typeToMap.Name));
                    typeInfo.ShouldNotBeNull();
                    typeInfo.Name.ShouldBe(typeToMap.ModelTypeName());

                    var defaultContext =
                        ((IModelApplicationModelMapper)application.Model).ModelMapper.MapperContexts.GetNode(
                            ModelMapperContextNodeGenerator.Default);
                    defaultContext.ShouldNotBeNull();
                    var modelMapper = defaultContext.GetNode(predefinedMap.DisplayName());
                    modelMapper.ShouldNotBeNull();
                }
            }
        }
        public void ExtendModel_Predefined_Type(PredefinedMap configuration, Type typeToMap, string platformName, string nodePath)
        {
            var platform = GetPlatform(platformName);

            Assembly.LoadFile(typeToMap.Assembly.Location);
            InitializeMapperService(platform);
            using var module      = configuration.Extend();
            using var application = DefaultModelMapperModule(platform, module).Application;
            AssertExtendedListViewModel(typeToMap, application, nodePath);
        }
        internal void ExtendModel_Predefined_Type(PredefinedMap configuration, Type typeToMap, Platform platform, string nodePath)
        {
            Assembly.LoadFile(typeToMap.Assembly.Location);
            InitializeMapperService($"{nameof(ExtendModel_Predefined_Type)}{configuration}{platform}", platform);

            var module      = configuration.Extend();
            var application = DefaultModelMapperModule(platform, module).Application;

            AssertExtendedListViewModel(typeToMap, application, nodePath);
        }
Пример #4
0
        public void ExtendModel_PredefinedChartDiagram(PredefinedMap configuration, Type typeToMap, string platformName)
        {
            var platform = GetPlatform(platformName);

            InitializeMapperService($"{nameof(ExtendModel_PredefinedChartDiagram)}{configuration}{platform}", platform);

            using (var module = PredefinedMap.ChartControl.Extend()){
                configuration.Extend(module);
                using (var application = DefaultModelMapperModule(nameof(ExtendModel_PredefinedChartDiagram), platform, module).Application){
                    var modelListView = application.Model.Views.OfType <IModelListView>().First();
                    var modelNode     = modelListView.GetNode(PredefinedMap.ChartControl);
                    modelNode = modelNode.GetNode("Diagrams");

                    var diagramType = modelNode.ModelListItemType();
                    var targetType  = diagramType.Assembly.GetType(configuration.ModelTypeName());
                    diagramType.IsAssignableFrom(targetType).ShouldBeTrue();
                }
            }
        }