Example #1
0
        private void UpdateObjectCount(PacketInfoData o)
        {
            // add only of it's not a control message
            // and it's not out of band
            FormatEntryData fed = o as FormatEntryData;

            if (fed == null || fed.outOfBand)
            {
                return;
            }

            _currentObjectCount++;
        }
Example #2
0
        private void Notify()
        {
            if (_notificationCallBack == null)
            {
                return;
            }

            // filter out the out of band data, since they do not participate in the
            // auto resize algorithm
            List <PacketInfoData> validObjects = new List <PacketInfoData>();

            foreach (PacketInfoData x in _queue)
            {
                FormatEntryData fed = x as FormatEntryData;
                if (fed != null && fed.outOfBand)
                {
                    continue;
                }

                validObjects.Add(x);
            }

            _notificationCallBack(_formatStartData, validObjects);
        }
        /// <summary>
        /// Process an object from an input stream. It manages the context stack and
        /// calls back on the specified event delegates.
        /// </summary>
        /// <param name="o">Object to process.</param>
        internal void Process(object o)
        {
            PacketInfoData  formatData = o as PacketInfoData;
            FormatEntryData fed        = formatData as FormatEntryData;

            if (fed != null)
            {
                OutputContext ctx = null;

                if (!fed.outOfBand)
                {
                    ctx = _stack.Peek();
                }
                //  notify for Payload
                this.payload(fed, ctx);
            }
            else
            {
                bool formatDataIsFormatStartData = formatData is FormatStartData;
                bool formatDataIsGroupStartData  = formatData is GroupStartData;
                // it's one of our formatting messages
                // we assume for the moment that they are in the correct sequence
                if (formatDataIsFormatStartData || formatDataIsGroupStartData)
                {
                    OutputContext oc = this.contextCreation(this.ActiveOutputContext, formatData);
                    _stack.Push(oc);

                    // now we have the context properly set: need to notify the
                    // underlying algorithm to do the start document or group stuff
                    if (formatDataIsFormatStartData)
                    {
                        // notify for Fs
                        this.fs(oc);
                    }
                    else if (formatDataIsGroupStartData)
                    {
                        // GroupStartData gsd = (GroupStartData) formatData;
                        // notify for Gs
                        this.gs(oc);
                    }
                }
                else
                {
                    GroupEndData  ged   = formatData as GroupEndData;
                    FormatEndData fEndd = formatData as FormatEndData;
                    if (ged != null || fEndd != null)
                    {
                        OutputContext oc = _stack.Peek();
                        if (fEndd != null)
                        {
                            // notify for Fe, passing the Fe info, before a Pop()
                            this.fe(fEndd, oc);
                        }
                        else if (ged != null)
                        {
                            // notify for Fe, passing the Fe info, before a Pop()
                            this.ge(ged, oc);
                        }

                        _stack.Pop();
                    }
                }
            }
        }