本文整理汇总了C#中TEXT_POSITION类的典型用法代码示例。如果您正苦于以下问题:C# TEXT_POSITION类的具体用法?C# TEXT_POSITION怎么用?C# TEXT_POSITION使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TEXT_POSITION类属于命名空间,在下文中一共展示了TEXT_POSITION类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
// Binds this pending breakpoint to one or more code locations.
int IDebugPendingBreakpoint2.Bind() {
if (CanBind()) {
// Get the location in the document that the breakpoint is in.
var startPosition = new TEXT_POSITION[1];
var endPosition = new TEXT_POSITION[1];
string fileName;
var docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_bpRequestInfo.bpLocation.unionmember2));
EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
EngineUtils.CheckOk(docPosition.GetFileName(out fileName));
_breakpoint = _engine.Process.AddBreakpoint(
fileName,
(int)startPosition[0].dwLine,
(int)startPosition[0].dwColumn,
_enabled,
AD7BoundBreakpoint.GetBreakOnForPassCount(_bpRequestInfo.bpPassCount),
_bpRequestInfo.bpCondition.bstrCondition);
_bpManager.AddPendingBreakpoint(_breakpoint, this);
_breakpoint.BindAsync().WaitAsync(TimeSpan.FromSeconds(2)).Wait();
return VSConstants.S_OK;
}
// The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
// The sample engine does not support this, but a real world engine will want to send an instance of IDebugBreakpointErrorEvent2 to the
// UI and return a valid instance of IDebugErrorBreakpoint2 from IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then
// display information about why the breakpoint did not bind to the user.
return VSConstants.S_FALSE;
}
示例2: AD7DocumentContext
public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
{
_fileName = fileName;
_begPos = begPos;
_endPos = endPos;
_codeContext = codeContext;
}
示例3: lock
// Binds this pending breakpoint to one or more code locations.
int IDebugPendingBreakpoint2.Bind()
{
try {
if (CanBind()) {
var docPosition = (IDebugDocumentPosition2)Marshal.GetObjectForIUnknown(m_bpRequestInfo.bpLocation.unionmember2);
// Get the name of the document that the breakpoint was put in
string documentName;
EngineUtils.CheckOk(docPosition.GetFileName(out documentName));
// Get the location in the document that the breakpoint is in.
var startPosition = new TEXT_POSITION[1];
var endPosition = new TEXT_POSITION[1];
EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
var id = m_engine.DebuggedProcess.SetBreakpoint(documentName, startPosition[0].dwLine, startPosition[0].dwColumn);
if (id == -1)
return Constants.S_FALSE;
lock (this)
m_boundBreakpoints.Add(new AD7BoundBreakpoint(m_engine, id, this));
return Constants.S_OK;
} else {
// The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
// The sample engine does not support this, but a real world engine will want to send an instance of IDebugBreakpointErrorEvent2 to the
// UI and return a valid instance of IDebugErrorBreakpoint2 from IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then
// display information about why the breakpoint did not bind to the user.
return Constants.S_FALSE;
}
} catch (Exception e) {
return EngineUtils.UnexpectedException(e);
}
}
示例4: AD7MemoryAddress
public AD7MemoryAddress(AD7Engine engine, string filename, uint lineno, PythonStackFrame frame = null) {
_engine = engine;
_lineNo = (uint)lineno;
_filename = filename;
var pos = new TEXT_POSITION { dwLine = lineno, dwColumn = 0 };
_documentContext = new AD7DocumentContext(filename, pos, pos, this, frame != null ? frame.Kind : FrameKind.None);
}
示例5: AD7DocumentContext
public AD7DocumentContext(string fileName, int lineNumber, TEXT_POSITION beginPosition, TEXT_POSITION endPosition, RoutineScope rs)
{
Debug.WriteLine("AD7DocumentContext: ctor");
_fileName = fileName;
_beginPosition = beginPosition;
_endPosition = endPosition;
_lineNumber = lineNumber;
_rs = rs;
}
示例6: AD7DocumentContext
/// <summary>
/// Constructor.
/// </summary>
/// <param name="fileName"> Short path file name. </param>
/// <param name="begPos"> Start position. </param>
/// <param name="endPos"> End position. In VSNDK debug engine, both begPos and endPos have the same value. </param>
/// <param name="codeContext"> An address in a program's execution stream. </param>
public AD7DocumentContext(string fileName, TEXT_POSITION begPos, TEXT_POSITION endPos, AD7MemoryAddress codeContext)
{
// Need to lengthen the path used by Visual Studio.
StringBuilder documentNameSB = new StringBuilder(1024);
GetLongPathName(fileName, documentNameSB, documentNameSB.Capacity);
m_fileName = documentNameSB.ToString();
m_begPos = begPos;
m_endPos = endPos;
m_codeContext = codeContext;
}
示例7: GetSourceRange
public int GetSourceRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
{
Log.Debug("ScriptDocumentContext: GetSourceRange");
pBegPosition[0].dwLine = (uint)_line;
pBegPosition[0].dwColumn = (uint)_column;
pEndPosition[0].dwLine = (uint)_line;
pEndPosition[0].dwColumn = (uint)_column;
return VSConstants.S_OK;
}
示例8: DebuggeeDocumentContext
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public DebuggeeDocumentContext (DebugEngine engine, string fileName, TEXT_POSITION beginPosition, TEXT_POSITION endPosition)
{
m_engine = engine;
m_fileName = PathUtils.ConvertPathCygwinToWindows (fileName);
m_beginPosition = beginPosition;
m_endPosition = endPosition;
m_codeContext = null;
}
示例9: GetLocation
public void GetLocation(out string fileName, out int lineNumber, out TEXT_POSITION start, out TEXT_POSITION end) {
var docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(_requestInfo.bpLocation.unionmember2));
Marshal.ThrowExceptionForHR(docPosition.GetFileName(out fileName));
var pStart = new TEXT_POSITION[1];
var pEnd = new TEXT_POSITION[1];
Marshal.ThrowExceptionForHR(docPosition.GetRange(pStart, pEnd));
start = pStart[0];
end = pEnd[0];
lineNumber = (int)start.dwLine + 1;
}
示例10: GetStatementRange
/// <summary>
/// Gets the file statement range of the document context.
/// A statement range is the range of the lines that contributed the code to which this document context refers.
/// </summary>
public int GetStatementRange(TEXT_POSITION[] pBegPosition, TEXT_POSITION[] pEndPosition)
{
DLog.Debug(DContext.VSDebuggerComCall, "DebugDocumentContext.GetStatementRange");
var position = DocumentLocation.Position;
if (position == null)
return VSConstants.E_FAIL;
// TEXT_POSITION starts counting at 0
pBegPosition[0].dwLine = (uint) (position.Start.Line - 1);
pBegPosition[0].dwColumn = (uint) (position.Start.Column - 1);
pEndPosition[0].dwLine = (uint) (position.End.Line - 1);
pEndPosition[0].dwColumn = (uint) (position.End.Column - 1);
DLog.Debug(DContext.VSDebuggerComCall, "Range: {0}-{1}", position.Start, position.End);
return VSConstants.S_OK;
}
示例11: catch
int IDebugStackFrame2.GetDocumentContext(out IDebugDocumentContext2 ppCxt) {
var pos = new TEXT_POSITION { dwColumn = 0, dwLine = (uint)((StackFrame.LineNumber - 1) ?? 0) };
string fileName = StackFrame.FileName;
if (fileName != null) {
try {
fileName = Path.GetFullPath(fileName);
} catch (Exception) {
}
}
ppCxt = new AD7DocumentContext(fileName, pos, pos, null);
return VSConstants.S_OK;
}
示例12: GetRange
public static TextSpan GetRange(this IDebugDocumentPosition2 documentPosition)
{
Contract.Requires<ArgumentNullException>(documentPosition != null, "documentPosition");
TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
ErrorHandler.ThrowOnFailure(documentPosition.GetRange(startPosition, endPosition));
return new TextSpan()
{
iStartLine = (int)startPosition[0].dwLine,
iStartIndex = (int)startPosition[0].dwColumn,
iEndLine = (int)endPosition[0].dwLine,
iEndIndex = (int)endPosition[0].dwColumn
};
}
示例13: GetDocumentContext
// Get the document context for this pending breakpoint. A document context is a abstract representation of a source file
// location.
public AD7DocumentContext GetDocumentContext(uint address) {
IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)(Marshal.GetObjectForIUnknown(mBpRequestInfo.bpLocation.unionmember2));
string documentName;
EngineUtils.CheckOk(docPosition.GetFileName(out documentName));
// Get the location in the document that the breakpoint is in.
TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
TEXT_POSITION[] endPosition = new TEXT_POSITION[1];
EngineUtils.CheckOk(docPosition.GetRange(startPosition, endPosition));
AD7MemoryAddress codeContext = new AD7MemoryAddress(mEngine, address);
return new AD7DocumentContext(documentName, startPosition[0], startPosition[0], codeContext);
}
示例14: GetTextLine
public static string GetTextLine(IDebugDocumentContext2 context, TEXT_POSITION start, TEXT_POSITION end)
{
//IVsTextManager2 tm2 = (IVsTextManager2)serviceProvider.GetService(typeof(SVsTextManager));
//IVsTextView activeView;
//int hResult = tm2.GetActiveView2(1, null, (uint)_VIEWFRAMETYPE.vftCodeWindow, out activeView);
string name;
context.GetName(enum_GETNAME_TYPE.GN_MONIKERNAME, out name);
IVsTextView txtView;
Debugger.ShowSource(context, 0, 0, 0, 0, out txtView);
if (txtView != null)
{
string line;
txtView.GetTextStream((int)start.dwLine, (int)start.dwColumn, (int)end.dwLine, (int)end.dwColumn, out line);
return line;
}
return null;
}
示例15: GetDocumentText
public static string GetDocumentText(IDebugDocumentText2 pText, TEXT_POSITION pos)
{
string documentText = string.Empty;
if (pText != null)
{
uint numLines = 0;
uint numChars = 0;
int hr;
hr = pText.GetSize(ref numLines, ref numChars);
if (ErrorHandler.Succeeded(hr))
{
IntPtr buffer = Marshal.AllocCoTaskMem((int)numChars * sizeof(char));
uint actualChars = 0;
hr = pText.GetText(pos, numChars, buffer, out actualChars);
if (ErrorHandler.Succeeded(hr))
{
documentText = Marshal.PtrToStringUni(buffer, (int)actualChars);
}
Marshal.FreeCoTaskMem(buffer);
}
}
return documentText;
}