本文整理汇总了C#中IOleCommandTarget.Exec方法的典型用法代码示例。如果您正苦于以下问题:C# IOleCommandTarget.Exec方法的具体用法?C# IOleCommandTarget.Exec怎么用?C# IOleCommandTarget.Exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOleCommandTarget
的用法示例。
在下文中一共展示了IOleCommandTarget.Exec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
protected override bool Execute(uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut, IOleCommandTarget nextCommandTarget)
{
var groupId = CommandGroupId;
if (nextCommandTarget.Exec(ref groupId, nCmdID, nCmdexecopt, pvaIn, pvaOut) == VSConstants.S_OK)
{
// parse the content
var tokenizer = new RwHtmlTokenizer();
var text = TextView.TextSnapshot.GetText();
tokenizer.Tokenize(new StringReader(text));
var parser = new RwHtmlParser();
var node = parser.Parse(tokenizer.Tokens);
// prepare the metadata control resolver
var completionSource = TextView.TextBuffer.Properties.GetProperty<RwHtmlCompletionSource>(typeof(RwHtmlCompletionSource));
var metadataControlResolver = completionSource.MetadataControlResolver;
metadataControlResolver.ReloadAllControls(completionSource.GetCompletionContext());
try
{
CompletionHelper.DTE.UndoContext.Open("Format RWHTML document");
var edit = TextView.TextBuffer.CreateEdit(EditOptions.None, null, null);
// fix the casing of all elements
var editText = new StringBuilder(text);
foreach (var element in node.EnumerateNodes().OfType<RwHtmlElementNode>())
{
FixElement(editText, metadataControlResolver, TextView.TextBuffer, element);
}
edit.Replace(0, editText.Length, editText.ToString());
edit.Apply();
}
finally
{
CompletionHelper.DTE.UndoContext.Close();
}
}
return true;
}
示例2: WrapExec
public static int WrapExec(
IOleCommandTarget receiver,
IOleCommandTarget implementer,
ref System.Guid pguidCmdGroup,
uint nCmdID,
uint nCmdexecopt,
System.IntPtr pvaIn,
System.IntPtr pvaOut) {
Debug.Assert(receiver != null);
var commandId = new CommandID(pguidCmdGroup, (int)nCmdID);
if (LogCommand(commandId)) {
Logger.LogInfo("WrapExec: => recv={0}, impl={1}, parent={2}",
receiver,
GetImplementerString(implementer),
GetParentTargetString(implementer));
}
var hr = (implementer == null)
? (int)Constants.OLECMDERR_E_NOTSUPPORTED
: implementer.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
// Ensures OleMenuCommandService returns OLECMDERR_E_NOTSUPPORTED.
if (hr == VSConstants.S_OK && implementer is OleMenuCommandService) {
// Ensure we return OLECMDERR_E_NOTSUPPORTED instead of S_OK if our
// command does not support the command id. This is necessary so that
// the VS Shell chains the Exec call to other IOleCommandTarget
// implementations.
var service = (OleMenuCommandService)implementer;
var command = service.FindCommand(commandId);
if (command != null) {
if (!command.Supported) {
hr = (int)Constants.OLECMDERR_E_NOTSUPPORTED;
}
}
}
if (LogCommand(commandId)) {
Logger.LogInfo("WrapExec: <= recv={0}, impl={1}, parent={2}, hr={3}",
receiver,
GetImplementerString(implementer),
GetParentTargetString(implementer),
HrToString(hr));
}
return hr;
}