Пример #1
0
        internal SLTupleSet Clone()
        {
            SLTupleSet ts = new SLTupleSet();

            ts.MaxRank       = this.MaxRank;
            ts.SetDefinition = this.SetDefinition;
            ts.SortType      = this.SortType;
            ts.QueryFailed   = this.QueryFailed;

            ts.Tuples = new List <SLTuplesType>();
            foreach (SLTuplesType tt in this.Tuples)
            {
                ts.Tuples.Add(tt.Clone());
            }

            ts.HasSortByTuple = this.HasSortByTuple;
            ts.SortByTuple    = this.SortByTuple.Clone();

            return(ts);
        }
        internal void FromTupleCache(TupleCache tc)
        {
            this.SetAllNull();

            // I decided to do this one by one instead of just running through all the child
            // elements. Mainly because this seems safer... so complicated! It's just a pivot table
            // for goodness sakes...

            if (tc.Entries != null)
            {
                this.Entries.FromEntries(tc.Entries);
                this.HasEntries = true;
            }

            if (tc.Sets != null)
            {
                SLTupleSet ts;
                using (OpenXmlReader oxr = OpenXmlReader.Create(tc.Sets))
                {
                    while (oxr.Read())
                    {
                        if (oxr.ElementType == typeof(TupleSet))
                        {
                            ts = new SLTupleSet();
                            ts.FromTupleSet((TupleSet)oxr.LoadCurrentElement());
                            this.Sets.Add(ts);
                        }
                    }
                }
            }

            if (tc.QueryCache != null)
            {
                SLQuery q;
                using (OpenXmlReader oxr = OpenXmlReader.Create(tc.QueryCache))
                {
                    while (oxr.Read())
                    {
                        if (oxr.ElementType == typeof(Query))
                        {
                            q = new SLQuery();
                            q.FromQuery((Query)oxr.LoadCurrentElement());
                            this.QueryCache.Add(q);
                        }
                    }
                }
            }

            if (tc.ServerFormats != null)
            {
                SLServerFormat sf;
                using (OpenXmlReader oxr = OpenXmlReader.Create(tc.ServerFormats))
                {
                    while (oxr.Read())
                    {
                        if (oxr.ElementType == typeof(ServerFormat))
                        {
                            sf = new SLServerFormat();
                            sf.FromServerFormat((ServerFormat)oxr.LoadCurrentElement());
                            this.ServerFormats.Add(sf);
                        }
                    }
                }
            }
        }