Exemplo n.º 1
0
        private void SearchFormatHandoff()
        {
            while (startIndexSearch < internalMemoryBuffer.Count)
            {
                byte[] locData = null;
                if (isFrameSearchingRequired)
                {
                    PositionFrame position = frameSearcher.GetPosition(internalMemoryBuffer, startIndexSearch);

                    if (position == null)
                    {
                        //Debugger.Break();
                    }
                    // frame not Found...
                    if (position.IsNullPosition())
                    {
                        startIndexSearch = position.GetNextSearchStartingPosition();

                        return;
                    }

                    // else if frame found.
                    startIndexSearch = position.GetNextSearchStartingPosition();

                    locData = new byte[position.GetFrameLength()];
                    int counter = 0;
                    for (int i = position.GetFrameStartPosition(); i < position.GetFrameStartPosition() + position.GetFrameLength(); i++)
                    {
                        // now first XOR ith Element of Internal Memory Buffer with 55 here
                        if (isDataFormattingRequired)
                        {
                            locData[counter++] = frameFormatter.FormatByte(internalMemoryBuffer[i]);
                        }
                        else
                        {
                            locData[counter++] = internalMemoryBuffer[i];
                        }
                    }
                }
                else
                {
                    // No frame search required now just copy the data to output buffer...

                    locData = new byte[internalMemoryBuffer.Count - startIndexSearch];

                    int dataCounter = 0;

                    for (int i = startIndexSearch; i < internalMemoryBuffer.Count; i++)
                    {
                        if (isDataFormattingRequired)
                        {
                            locData[dataCounter++] = frameFormatter.FormatByte(internalMemoryBuffer[i]);
                        }
                        else
                        {
                            locData[dataCounter++] = internalMemoryBuffer[i];
                        }
                    }
                    startIndexSearch = internalMemoryBuffer.Count;
                }
                // now Hand off data..
                transferBuffer.TryAdd(locData);

                //publisher.UpdateUserInterface(locData);
            }
        }