System.Diagnostics.StackFrameHelper.GetOffset C# (CSharp) Method

GetOffset() public method

public GetOffset ( int i ) : int
i int
return int
        public virtual int GetOffset (int i) { return rgiOffset [i];}
        public virtual int GetILOffset (int i) { return rgiILOffset [i];}

Usage Example

        // Retrieves an object with stack trace information encoded.
        // It leaves out the first "iSkip" lines of the stacktrace.
        //
        private void CaptureStackTrace(int iSkip, bool fNeedFileInfo, Thread targetThread,
                                       Exception e)
        {
            m_iMethodsToSkip += iSkip;

            StackFrameHelper StackF = new StackFrameHelper(fNeedFileInfo, targetThread);

            GetStackFramesInternal(StackF, 0, e);

            m_iNumOfFrames = StackF.GetNumberOfFrames();

            if (m_iMethodsToSkip > m_iNumOfFrames)
            {
                m_iMethodsToSkip = m_iNumOfFrames;
            }

            if (m_iNumOfFrames != 0)
            {
                frames = new StackFrame [m_iNumOfFrames];

                for (int i = 0; i < m_iNumOfFrames; i++)
                {
                    bool       fDummy1 = true;
                    bool       fDummy2 = true;
                    StackFrame sfTemp  = new StackFrame(fDummy1, fDummy2);

                    sfTemp.SetMethodBase(StackF.GetMethodBase(i));
                    sfTemp.SetOffset(StackF.GetOffset(i));
                    sfTemp.SetILOffset(StackF.GetILOffset(i));

                    if (fNeedFileInfo)
                    {
                        sfTemp.SetFileName(StackF.GetFilename(i));
                        sfTemp.SetLineNumber(StackF.GetLineNumber(i));
                        sfTemp.SetColumnNumber(StackF.GetColumnNumber(i));
                    }

                    frames [i] = sfTemp;
                }

                // CalculateFramesToSkip skips all frames in the System.Diagnostics namespace,
                // but this is not desired if building a stack trace from an exception.
                if (e == null)
                {
                    m_iMethodsToSkip += CalculateFramesToSkip(StackF, m_iNumOfFrames);
                }

                m_iNumOfFrames -= m_iMethodsToSkip;
                if (m_iNumOfFrames < 0)
                {
                    m_iNumOfFrames = 0;
                }
            }

            // In case this is the same object being re-used, set frames to null
            else
            {
                frames = null;
            }
        }
All Usage Examples Of System.Diagnostics.StackFrameHelper::GetOffset