public virtual DataBlocks Sort(DataBlock block)
        {
            DataBlocks result = new DataBlocks();

            if ((andList == null || andList.Count == 0) && (orList == null || orList.Count == 0) && (appendList == null || appendList.Count == 0))
            {
                result.AddDataBlock(block);
            }
            if (andList != null && andList.Count > 0)
            {
                IList <DataBlock> blocks = new List <DataBlock>();
                blocks.Add(block);
                IList <DataBlock> temps = new List <DataBlock>();
                foreach (ISelectOrder order in andList)
                {
                    temps.Clear();
                    foreach (DataBlock bl in blocks)
                    {
                        DataBlocks dbs = order.Sort(bl);
                        foreach (DataBlock db in dbs.GetBlocks())
                        {
                            temps.Add(db);
                        }
                    }
                    if (temps.Count == 0)
                    {
                        return(new DataBlocks());
                    }
                    blocks.Clear();
                    Sharpen.Collections.AddAll(blocks, temps);
                }
                foreach (DataBlock bl_1 in blocks)
                {
                    result.AddDataBlock(bl_1);
                }
            }
            if (orList != null && orList.Count > 0)
            {
                DataBlocks orResult = new DataBlocks();
                foreach (ISelectOrder order in orList)
                {
                    orResult = orResult.OrMerge(order.Sort(block));
                }
                if (andList != null && andList.Count > 0)
                {
                    result = result.AndMerge(orResult);
                }
                else
                {
                    result = orResult;
                }
            }
            if (appendList != null && appendList.Count > 0)
            {
                foreach (ISelectOrder order in appendList)
                {
                    result = result.AppendMerge(order.Sort(block));
                }
            }
            result.RemoveEmptyBlokcs();
            return(result);
        }
Exemple #2
0
 public virtual void AddDataBlock(DataBlock block)
 {
     this.blocks.Add(block);
 }