Пример #1
0
        public static IModelList <IModelObjectView> Get_Views(IModelMergedDifference differences)
        {
            var modelObjectView = ((IModelObjectView)differences.Parent.Parent);

            if (modelObjectView.ModelClass == null)
            {
                return(new CalculatedModelNodeList <IModelObjectView>(differences.Application.Views.OfType <IModelObjectView>()));
            }
            var modelObjectViews = differences.Application.Views.OfType <IModelObjectView>().Where(view
                                                                                                   => view.ModelClass != null && (view.ModelClass.TypeInfo.Type.IsAssignableFrom(modelObjectView.ModelClass.TypeInfo.Type)));

            return(new CalculatedModelNodeList <IModelObjectView>(modelObjectViews));
        }
Пример #2
0
        public static string GetViewId(this IModelMergedDifference modelMergedDifference, IEnumerable <ModelApplicationBase> modelApplicationBases)
        {
            var viewId = GetViewIdCore(modelMergedDifference);

            if (string.IsNullOrEmpty(viewId))
            {
                var id = modelMergedDifference.Parent.Parent.Id();
                var mergeDifferences = modelApplicationBases.Cast <IModelApplication>().Select(application =>
                                                                                               application.Views[id]).OfType <IModelObjectViewMergedDifferences>().Where(view =>
                                                                                                                                                                         view != null && view.MergedDifferences != null).SelectMany(differences => differences.MergedDifferences);
                viewId = mergeDifferences.Select(GetViewIdCore).First(value => !string.IsNullOrEmpty(value));
            }
            return(viewId);
        }
Пример #3
0
 void CloneNodes(IModelMergedDifference mergedDifference, IModelObjectView targetObjectView, IModelObjectView sourceObjectView)
 {
     foreach (var nodePath in GetIncludedNodePaths(mergedDifference))
     {
         CalculatedModelNodeList <IModelNode> items = null;
         var needsUpdate = nodePath.NodePath == "Items" || nodePath.NodePath == "Columns";
         if (needsUpdate)
         {
             var modelDetailView = targetObjectView as IModelDetailView;
             var modelNodes      = modelDetailView != null? (IEnumerable <IModelNode>)modelDetailView.Items: ((IModelListView)targetObjectView).Columns;
             items = new CalculatedModelNodeList <IModelNode>(modelNodes);
         }
         RemoveUnrelatedNodes(targetObjectView, nodePath);
         CloneNodes(sourceObjectView, nodePath, targetObjectView);
         if (needsUpdate)
         {
             UpdateDetailViewItems(items, targetObjectView);
             UpdateColumns(items, targetObjectView, mergedDifference.InvisibleListViewColumns);
         }
     }
 }
Пример #4
0
 static string GetViewIdCore(IModelMergedDifference modelMergedDifference)
 {
     return(Regex.Match(((ModelNode)modelMergedDifference).Xml, "View=\"([^\"]*)",
                        RegexOptions.Singleline | RegexOptions.IgnoreCase).Groups[1].Value);
 }
Пример #5
0
        static void ReadViewsFromOtherLayers(IEnumerable <ModelApplicationBase> modelApplicationBases, IModelMergedDifference modelMergedDifference, ModelApplicationBase modelApplicationBase)
        {
            var applicationBases = modelApplicationBases as ModelApplicationBase[] ?? modelApplicationBases.ToArray();
            var viewId           = GetViewId(modelMergedDifference, applicationBases);
            var mergedView       = (IModelObjectView)applicationBases.Cast <IModelApplication>().Select(application
                                                                                                        => application.Views[viewId]).FirstOrDefault(view => view != null);
            var modelNode = (ModelNode)mergedView;

            if (modelNode != null)
            {
                string viewName = "DetailView";
                if (modelNode is IModelListView)
                {
                    viewName = "ListView";
                }
                var s   = @"<" + viewName + @" Id=""" + modelNode.Id + @"""></" + viewName + ">";
                var xml = "<Application><Views>" + s + "</Views></Application>";
                new ModelXmlReader().ReadFromString(modelApplicationBase, "", xml);
            }
        }
Пример #6
0
        private static string ViewId(IModelMergedDifference difference)
        {
            var regexObj = new Regex("View=\"([^\"]*)\"");

            return(regexObj.Match(difference.Xml()).Groups[1].Value);
        }
Пример #7
0
 public static IModelList <IModelMergedDifferenceStrategy> Get_Strategies(IModelMergedDifference differences)
 {
     return(new CalculatedModelNodeList <IModelMergedDifferenceStrategy>(((IModelOptionsMergedDifferenceStrategy)differences.Application.Options).MergedDifferenceStrategies));
 }
Пример #8
0
 public static IModelMergedDifferenceStrategy Get_Strategy(IModelMergedDifference differences)
 {
     return(Get_Strategies(differences).FirstOrDefault(strategy => strategy.Id() == MergedDifferencesStrategiesGenerator.Everything));
 }
Пример #9
0
 public ModelMergedDifferenceInfo(IModelMergedDifference modelMergedDifference, string mergedViewId)
 {
     _modelMergedDifference = modelMergedDifference;
     _mergedViewId          = mergedViewId;
     _targetView            = modelMergedDifference.Parent.Parent;
 }
Пример #10
0
 IEnumerable <IModelMergedDifferenceStrategyIncludedNodePath> GetIncludedNodePaths(IModelMergedDifference mergedDifference)
 {
     return(GetIncludedNodePaths((IModelObjectView)mergedDifference.Parent.Parent, mergedDifference.Strategy));
 }
Пример #11
0
 public static IModelList <IModelObjectView> Get_Views(IModelMergedDifference differences)
 => ((IModelObjectView)differences.Parent.Parent).ModelClass == null
         ? new CalculatedModelNodeList <IModelObjectView>(differences.Application.Views.OfType <IModelObjectView>())
         : new CalculatedModelNodeList <IModelObjectView>(differences.Application.Views.OfType <IModelObjectView>()
                                                          .Where(view => view.ModelClass != null));