Exemple #1
0
 public static Type ModelViewType(CloneViewType viewType)
 {
     if (viewType == CloneViewType.ListView || viewType == CloneViewType.LookupListView)
     {
         return(typeof(IModelListView));
     }
     return(typeof(IModelDetailView));
 }
Exemple #2
0
        internal void Clone_Model_View_and_make_it_default(CloneViewType cloneViewType, Platform platform)
        {
            var cloneViewId = $"test_{cloneViewType}";

            var application = DefaultCloneModelViewModule(info => {
                var cloneModelViewAttribute = new CloneModelViewAttribute(cloneViewType, cloneViewId, true);
                info.FindTypeInfo(typeof(CMV)).AddAttribute(cloneModelViewAttribute);
            }, platform).Application;
            var modelView = application.Model.Views[cloneViewId].AsObjectView;

            ((IModelView)modelView.ModelClass.GetPropertyValue($"Default{cloneViewType}")).Id.ShouldBe(cloneViewId);
        }
        public void Keep_ModelGenerators(CloneViewType cloneViewType)
        {
            var cloneViewId          = $"{nameof(Keep_ModelGenerators)}_{cloneViewType}";
            var cloneModelViewModule = new CloneModelViewModule();

            cloneModelViewModule.RequiredModuleTypes.Add(typeof(ModelViewInheritanceModule));
            using var application = DefaultCloneModelViewModule(cloneModelViewModule, info => {
                var typeInfo = info.FindTypeInfo(typeof(CMV));
                typeInfo.AddAttribute(new CloneModelViewAttribute(cloneViewType, cloneViewId));
                typeInfo.AddAttribute(new ModelMergedDifferencesAttribute(cloneViewId, $"CMV_{cloneViewType}"));
            }, Platform.Win)
                                    .Application;
            ((IModelObjectViewMergedDifferences)application.Model.Views[cloneViewId]).MergedDifferences.Count.ShouldBe(1);
        }
Exemple #4
0
        internal void Clone_Model_View(CloneViewType cloneViewType, Platform platform)
        {
            var cloneViewId = $"test_{cloneViewType}";

            var application = DefaultCloneModelViewModule(info => {
                var cloneModelViewAttribute = new CloneModelViewAttribute(cloneViewType, cloneViewId);
                info.FindTypeInfo(typeof(CMV)).AddAttribute(cloneModelViewAttribute);
            }, platform).Application;
            var modelView = application.Model.Views[cloneViewId];

            modelView.ShouldNotBeNull();
            modelView.GetType().Name.ShouldBe($"Model{cloneViewType.ToString().Replace("Lookup", "")}");
            modelView.Id.ShouldBe(cloneViewId);
        }
Exemple #5
0
        public void Clone_Model_View_and_make_it_default(CloneViewType cloneViewType, string platformName)
        {
            var platform    = GetPlatform(platformName);
            var cloneViewId = $"{nameof(Clone_Model_View_and_make_it_default)}_{cloneViewType}{platform}";

            var application = DefaultCloneModelViewModule(info => {
                var cloneModelViewAttribute = new CloneModelViewAttribute(cloneViewType, cloneViewId, true);
                info.FindTypeInfo(typeof(CMV)).AddAttribute(cloneModelViewAttribute);
            }, platform).Application;
            var modelView = application.Model.Views[cloneViewId].AsObjectView;

            ((IModelView)modelView.ModelClass.GetPropertyValue($"Default{cloneViewType}")).Id
            .ShouldBe(cloneViewId);
            application.Dispose();
        }
Exemple #6
0
        internal void Clone_Model_ListView_and_change_its_detailview(CloneViewType cloneViewType, Platform platform)
        {
            var cloneViewId  = "test_";
            var listViewId   = $"{cloneViewId}{cloneViewType}";
            var detailViewId = $"{cloneViewType}DetailView";
            var application  = DefaultCloneModelViewModule(info => {
                var typeInfo = info.FindTypeInfo(typeof(CMV));
                typeInfo.AddAttribute(new CloneModelViewAttribute(CloneViewType.DetailView, detailViewId));
                typeInfo.AddAttribute(new CloneModelViewAttribute(cloneViewType, listViewId)
                {
                    DetailView = detailViewId
                });
            }, platform).Application;
            var modelListView = (IModelListView)application.Model.Views[listViewId];

            modelListView.DetailView.Id.ShouldBe(detailViewId);
        }
        public void Clone_Model_View(CloneViewType cloneViewType)
        {
            var cloneViewId = $"{nameof(Clone_Model_View)}_{cloneViewType}";

            var application = DefaultCloneModelViewModule(info => {
                var cloneModelViewAttribute = new CloneModelViewAttribute(cloneViewType, cloneViewId);
                info.FindTypeInfo(typeof(CMV)).AddAttribute(cloneModelViewAttribute);
            }).Application;

            ((bool)application.GetPropertyValue("EnableModelCache")).ShouldBe(false);

            var modelView = application.Model.Views[cloneViewId];

            modelView.ShouldNotBeNull();
            modelView.GetType().Name.ShouldBe($"Model{cloneViewType.ToString().Replace("Lookup", "")}");
            modelView.Id.ShouldBe(cloneViewId);
            application.Dispose();
        }
Exemple #8
0
        public void Clone_Model_ListView_and_change_its_detailview(CloneViewType cloneViewType, string platform)
        {
            var cloneViewId  = $"{nameof(Clone_Model_ListView_and_change_its_detailview)}{platform}_";
            var listViewId   = $"{cloneViewId}{cloneViewType}";
            var detailViewId = $"{cloneViewType}DetailView";
            var application  = DefaultCloneModelViewModule(info => {
                var typeInfo = info.FindTypeInfo(typeof(CMV));
                typeInfo.AddAttribute(new CloneModelViewAttribute(CloneViewType.DetailView, detailViewId));
                typeInfo.AddAttribute(new CloneModelViewAttribute(cloneViewType, listViewId)
                {
                    DetailView = detailViewId
                });
            }, (Platform)Enum.Parse(typeof(Platform), platform)).Application;
            var modelListView = (IModelListView)application.Model.Views[listViewId];

            modelListView.DetailView.Id.ShouldBe(detailViewId);
            application.Dispose();
        }
Exemple #9
0
 public CloneViewAttribute(CloneViewType viewType, string viewId)
 {
     _viewType = viewType;
     _viewId   = viewId;
 }
 public ModelMergedDifferencesAttribute(CloneViewType cloneViewType)
 {
     _cloneViewType = cloneViewType;
     Strategy       = MergedDifferencesStrategiesGenerator.EverythingButLayout;
 }
 public static Type ModelViewType(this CloneViewType viewType)
 => viewType == CloneViewType.ListView || viewType == CloneViewType.LookupListView
         ? typeof(IModelListView)
         : typeof(IModelDetailView);
Exemple #12
0
 public CloneModelViewAttribute(CloneViewType viewType, string viewId, bool isDefault = false)
 {
     ViewType  = viewType;
     ViewId    = viewId;
     IsDefault = isDefault;
 }
Exemple #13
0
 public CloneViewAttribute(CloneViewType viewType, string viewId, bool isDefault = false)
 {
     _viewType  = viewType;
     _viewId    = viewId;
     _isDefault = isDefault;
 }