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)); }
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); }
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); } } }
static string GetViewIdCore(IModelMergedDifference modelMergedDifference) { return(Regex.Match(((ModelNode)modelMergedDifference).Xml, "View=\"([^\"]*)", RegexOptions.Singleline | RegexOptions.IgnoreCase).Groups[1].Value); }
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); } }
private static string ViewId(IModelMergedDifference difference) { var regexObj = new Regex("View=\"([^\"]*)\""); return(regexObj.Match(difference.Xml()).Groups[1].Value); }
public static IModelList <IModelMergedDifferenceStrategy> Get_Strategies(IModelMergedDifference differences) { return(new CalculatedModelNodeList <IModelMergedDifferenceStrategy>(((IModelOptionsMergedDifferenceStrategy)differences.Application.Options).MergedDifferenceStrategies)); }
public static IModelMergedDifferenceStrategy Get_Strategy(IModelMergedDifference differences) { return(Get_Strategies(differences).FirstOrDefault(strategy => strategy.Id() == MergedDifferencesStrategiesGenerator.Everything)); }
public ModelMergedDifferenceInfo(IModelMergedDifference modelMergedDifference, string mergedViewId) { _modelMergedDifference = modelMergedDifference; _mergedViewId = mergedViewId; _targetView = modelMergedDifference.Parent.Parent; }
IEnumerable <IModelMergedDifferenceStrategyIncludedNodePath> GetIncludedNodePaths(IModelMergedDifference mergedDifference) { return(GetIncludedNodePaths((IModelObjectView)mergedDifference.Parent.Parent, mergedDifference.Strategy)); }
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));