コード例 #1
0
        /// <summary>
        /// Creates the accumulated filter expression from current tree definition node, and all the nearest ancestor DataFolderElement-s that
        /// are related to the same data type.
        /// </summary>
        /// <param name="parameterExpression">The parameter expression.</param>
        /// <param name="affectedInterfaceType">Type of the affected interface.</param>
        /// <param name="dynamicContext">The dynamic context.</param>
        /// <param name="filtersToSkip">The filters to skip.</param>
        /// <returns></returns>
        internal Expression CreateAccumulatedFilterExpression(ParameterExpression parameterExpression, Type affectedInterfaceType, TreeNodeDynamicContext dynamicContext, IList <int> filtersToSkip = null)
        {
            TreeNode treeNode = this;

            Expression currentExpression = null;

            while (treeNode != null)
            {
                DataFilteringTreeNode dataFilteringTreeNode = treeNode as DataFilteringTreeNode;

                if (dataFilteringTreeNode != null &&
                    (dataFilteringTreeNode == this || dataFilteringTreeNode is DataFolderElementsTreeNode) &&
                    (dataFilteringTreeNode.CurrentDataInterfaceType == affectedInterfaceType))
                {
                    Expression filterExpression = dataFilteringTreeNode.CreateFilterExpression(parameterExpression, dynamicContext, filtersToSkip);

                    if (filterExpression != null)
                    {
                        currentExpression = currentExpression.NestedAnd(filterExpression);
                    }
                }
                else
                {
                    break;
                }

                treeNode = treeNode.ParentNode;
            }

            //currentExpression.DebugLogExpression("DataFileringTreeNode", "Accumulated Filter Expression");

            return(currentExpression);
        }
コード例 #2
0
        public static bool SelfAndParentsHasInterface(this TreeNode treeNode, Type interfaceType)
        {
            DataFilteringTreeNode dataFilteringTreeNode = null;

            while (treeNode != null)
            {
                dataFilteringTreeNode = treeNode as DataFilteringTreeNode;
                if (dataFilteringTreeNode != null)
                {
                    break;
                }

                treeNode = treeNode.ParentNode;
            }

            if (dataFilteringTreeNode == null)
            {
                return(false);
            }

            if (dataFilteringTreeNode.CurrentDataInterfaceType == interfaceType)
            {
                return(true);
            }

            return(treeNode.ParentNode.SelfAndParentsHasInterface(interfaceType));
        }
コード例 #3
0
        /// <exclude />
        protected override void OnInitialize()
        {
            if (this.InterfaceType != null && !typeof(IData).IsAssignableFrom(this.InterfaceType))
            {
                AddValidationError("TreeValidationError.Common.NotImplementingIData", this.InterfaceType, typeof(IData));
            }

            this.ParentIdEntries = new List <ParentIdEntry>();

            IEnumerable <TreeNode> treeNodes = this.OwnerNode.Descendants(true).ToList();

            foreach (TreeNode treeNode in treeNodes)
            {
                DataFilteringTreeNode dataFilteringTreeNode = treeNode as DataFilteringTreeNode;

                if (dataFilteringTreeNode == null)
                {
                    continue;
                }

                IEnumerable <ParentIdFilterNode> parentIdFilterNodes = dataFilteringTreeNode.FilterNodes.OfType <ParentIdFilterNode>().Evaluate();
                if (!parentIdFilterNodes.Any())
                {
                    continue;
                }

                foreach (ParentIdFilterNode parentIdFilterNode in parentIdFilterNodes)
                {
                    Type interfaceType = parentIdFilterNode.ParentFilterType;

                    IEnumerable <ForeignPropertyInfo> foreignPropertyInfos = DataReferenceFacade.GetForeignKeyProperties(this.InterfaceType, interfaceType);

                    foreach (ForeignPropertyInfo foreignPropertyInfo in foreignPropertyInfos)
                    {
                        var parentIdEntry = new ParentIdEntry(
                            interfaceType,
                            foreignPropertyInfo.TargetKeyPropertyInfo,
                            foreignPropertyInfo.SourcePropertyName
                            );

                        if (!this.ParentIdEntries.Contains(parentIdEntry))
                        {
                            this.ParentIdEntries.Add(parentIdEntry);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.CustomFormMarkupPath))
            {
                this.CustomFormMarkupPath = LoadAndValidateCustomFormMarkupPath(CustomFormMarkupPath);
            }
        }
コード例 #4
0
        /// <exclude />
        protected override void OnInitialize()
        {
            if ((this.InterfaceType != null) && (typeof(IData).IsAssignableFrom(this.InterfaceType) == false))
            {
                AddValidationError("TreeValidationError.Common.NotImplementingIData", this.InterfaceType, typeof(IData));
            }

            this.ParentIdEntrys = new List <ParentIdEntry>();

            IEnumerable <TreeNode> treeNodes = this.OwnerNode.Descendants(true).ToList();

            foreach (TreeNode treeNode in treeNodes)
            {
                DataFilteringTreeNode dataFilteringTreeNode = treeNode as DataFilteringTreeNode;

                if (dataFilteringTreeNode == null)
                {
                    continue;
                }

                IEnumerable <ParentIdFilterNode> parentIdFilterNodes = dataFilteringTreeNode.FilterNodes.OfType <ParentIdFilterNode>();
                if (parentIdFilterNodes.Count() == 0)
                {
                    continue;
                }

                foreach (ParentIdFilterNode parentIdFilterNode in parentIdFilterNodes)
                {
                    Type interfaceType = parentIdFilterNode.ParentFilterType;

                    IEnumerable <ForeignPropertyInfo> foreignPropertyInfos = DataReferenceFacade.GetForeignKeyProperties(this.InterfaceType, interfaceType);

                    foreach (ForeignPropertyInfo foreignPropertyInfo in foreignPropertyInfos)
                    {
                        ParentIdEntry parentIdEntry = new ParentIdEntry
                        {
                            TargetInterface    = interfaceType,
                            TargetPropertyInfo = foreignPropertyInfo.TargetKeyPropertyInfo,
                            SourcePropertyName = foreignPropertyInfo.SourcePropertyName
                        };

                        if (this.ParentIdEntrys.Contains(parentIdEntry) == false)
                        {
                            this.ParentIdEntrys.Add(parentIdEntry);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(this.CustomFormMarkupPath) == false)
            {
                try
                {
                    string path = PathUtil.Resolve(this.CustomFormMarkupPath);
                    if (C1File.Exists(path) == false)
                    {
                        AddValidationError("TreeValidationError.GenericAddDataAction.MissingMarkupFile", path);
                    }

                    XDocument document = XDocumentUtils.Load(path);

                    this.CustomFormMarkupPath = path;
                }
                catch
                {
                    AddValidationError("TreeValidationError.GenericAddDataAction.BadMarkupPath", this.CustomFormMarkupPath);
                }
            }
        }