コード例 #1
0
        private static void InitByDataFilter(List <DataFilterInfo> filterInfoList, DataFilter dataFilter, string parentID)
        {
            if (dataFilter == null)
            {
                return;
            }

            int imageIndex;

            if (dataFilter is Sql)
            {
                imageIndex = ImageIndex_SqlFilter;
            }
            else if (dataFilter is And)
            {
                imageIndex = ImageIndex_AndFilter;
            }
            else if (dataFilter is Or)
            {
                imageIndex = ImageIndex_OrFilter;
            }
            else
            {
                throw new Exception("不支持的过滤器类型").AddExceptionData("过滤器", dataFilter);
            }
            filterInfoList.Add(new DataFilterInfo()
            {
                ParentID   = parentID,
                ImageIndex = imageIndex,
                DataFilter = dataFilter
            });

            if (dataFilter is CompositeLogicFilter)
            {
                var childFilters = dataFilter.As <CompositeLogicFilter>().ChildFilters;
                if (childFilters.IsNotNullOrEmpty())
                {
                    foreach (var childFilter in childFilters)
                    {
                        InitByDataFilter(filterInfoList, childFilter, dataFilter.As <PaoObject>().ID);
                    }
                }
            }
        }