本文整理汇总了C#中EnvDTE类的典型用法代码示例。如果您正苦于以下问题:C# EnvDTE类的具体用法?C# EnvDTE怎么用?C# EnvDTE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnvDTE类属于命名空间,在下文中一共展示了EnvDTE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddProperty
public EnvDTE.CodeProperty AddProperty(string getterName, string putterName, object type, object position, EnvDTE.vsCMAccess access, object location)
{
return FileCodeModel.EnsureEditor(() =>
{
return FileCodeModel.AddProperty(LookupNode(), getterName, putterName, type, position, access);
});
}
示例2: GetSubProject
// http://social.msdn.microsoft.com/Forums/vstudio/en-US/36adcd56-5698-43ca-bcba-4527daabb2e3/finding-the-startup-project-in-a-complicated-solution
public static EnvDTE.Project GetSubProject(EnvDTE.Project project, string uniqueName)
{
EnvDTE.Project ret = null;
if (project != null)
{
if (project.UniqueName == uniqueName)
{
ret = project;
}
else if (project.Kind == vsProjectKindSolutionItems)
{
// Solution folder
foreach (EnvDTE.ProjectItem projectItem in project.ProjectItems)
{
ret = GetSubProject(projectItem.SubProject, uniqueName);
if (ret != null)
break;
}
}
}
return ret;
}
示例3: Transform
public override string Transform(string fullFileName, string text, EnvDTE.ProjectItem projectItem)
{
var tags = regexScripts.Matches(text).Cast<Match>().Reverse();
foreach (var match in tags)
{
var tagName = match.Groups[1].Value;
var attrs = match.Groups[2].Value;
var code = match.Groups[3].Value;
if (tagName.Is("script"))
{
code = JsEngine.Minify(fullFileName, code, projectItem, Xml.MinifyType.Unspecified,string.Empty);
}
else if (tagName.Is("style"))
{
int i = attrs.IndexOf("text/less", StringComparison.InvariantCultureIgnoreCase);
if (i > -1)
{
attrs = attrs.Substring(0, i) + "text/css" + attrs.Substring(i + "text/less".Length);
code = code.Replace("@@import", "@import"); // Razor views need the @ symbol to be escaped :/
code = LessEngine.TransformToCss(fullFileName, code, projectItem);
code = code.Replace("@import", "@@import"); // Now we have to re-escape it
}
code = CssEngine.Minify(fullFileName, code, projectItem, Xml.MinifyType.Unspecified);
}
text = text.Substring(0, match.Index)
+ '<' + tagName + attrs + '>' + code + "</" + tagName + '>'
+ text.Substring(match.Index + match.Length);
}
return text;
}
示例4: GetActiveProject
private bool GetActiveProject(out EnvDTE.Project project, out FrameworkName frameworkName)
{
project = null;
frameworkName = null;
IntPtr hierarchyPointer = IntPtr.Zero;
IntPtr selectionContainerPointer = IntPtr.Zero;
try
{
uint itemid;
IVsMultiItemSelect multiItemSelect;
Marshal.ThrowExceptionForHR(
_monitorSelection.GetCurrentSelection(
out hierarchyPointer,
out itemid,
out multiItemSelect,
out selectionContainerPointer));
if (itemid != (uint)VSConstants.VSITEMID.Root)
{
return false;
}
var hierarchy = Marshal.GetObjectForIUnknown(hierarchyPointer) as IVsHierarchy;
if (hierarchy == null)
{
return false;
}
object extensibilityObject;
object targetFrameworkVersion;
object targetFrameworkMonikerObject;
Marshal.ThrowExceptionForHR(
hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ExtObject, out extensibilityObject));
Marshal.ThrowExceptionForHR(
hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID3.VSHPROPID_TargetFrameworkVersion, out targetFrameworkVersion));
Marshal.ThrowExceptionForHR(
hierarchy.GetProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID4.VSHPROPID_TargetFrameworkMoniker, out targetFrameworkMonikerObject));
string targetFrameworkMoniker = targetFrameworkMonikerObject as string;
frameworkName = new System.Runtime.Versioning.FrameworkName(targetFrameworkMoniker);
project = extensibilityObject as EnvDTE.Project;
return true;
}
finally
{
if (hierarchyPointer != IntPtr.Zero)
{
Marshal.Release(hierarchyPointer);
}
if (selectionContainerPointer != IntPtr.Zero)
{
Marshal.Release(selectionContainerPointer);
}
}
}
示例5: ToHierarchy
public static IVsHierarchy ToHierarchy(EnvDTE.Project project)
{
if (project == null) throw new ArgumentNullException("project");
string uniqueName = project.UniqueName;
IVsSolution solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
IVsHierarchy hierarchy;
solution.GetProjectOfUniqueName(uniqueName, out hierarchy);
return hierarchy;
/*if (project == null) throw new ArgumentNullException("project"); string projectGuid = null; // DTE does not expose the project GUID that exists at in the msbuild project file. // Cannot use MSBuild object model because it uses a static instance of the Engine, // and using the Project will cause it to be unloaded from the engine when the // GC collects the variable that we declare.
using (XmlReader projectReader = XmlReader.Create(project.FileName))
{
projectReader.MoveToContent();
object nodeName = projectReader.NameTable.Add("ProjectGuid");
while (projectReader.Read())
{
if (Object.Equals(projectReader.LocalName, nodeName))
{
projectGuid = (String)projectReader.ReadElementContentAsString(); break;
}
}
}
Debug.Assert(!String.IsNullOrEmpty(projectGuid));
IServiceProvider serviceProvider = new ServiceProvider(project.DTE as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); return VsShellUtilities.GetHierarchy(serviceProvider, new Guid(projectGuid));*/
}
示例6: GetExpandedProjectHierarchyItems
private static ICollection<VsHierarchyItem> GetExpandedProjectHierarchyItems(EnvDTE.Project project)
{
VsHierarchyItem projectHierarchyItem = GetHierarchyItemForProject(project);
IVsUIHierarchyWindow solutionExplorerWindow = GetSolutionExplorerHierarchyWindow();
if (solutionExplorerWindow == null)
{
// If the solution explorer is collapsed since opening VS, this value is null. In such a case, simply exit early.
return new VsHierarchyItem[0];
}
var expandedItems = new List<VsHierarchyItem>();
// processCallback return values:
// 0 continue,
// 1 don't recurse into,
// -1 stop
projectHierarchyItem.WalkDepthFirst(
fVisible: true,
processCallback:
(VsHierarchyItem vsItem, object callerObject, out object newCallerObject) =>
{
newCallerObject = null;
if (IsVsHierarchyItemExpanded(vsItem, solutionExplorerWindow))
{
expandedItems.Add(vsItem);
}
return 0;
},
callerObject: null);
return expandedItems;
}
示例7: FireOnBuildDone
public void FireOnBuildDone(EnvDTE.vsBuildScope scope, EnvDTE.vsBuildAction action)
{
if (OnBuildDone != null)
{
OnBuildDone(scope, action);
}
}
示例8: UpdateGeneratedCodeWizard
public UpdateGeneratedCodeWizard(EnvDTE.DTE dte)
{
InitializeComponent();
DataContext = this;
_dte = dte;
Loaded += (_, __) => Run().ConfigureAwait(true);
}
示例9: OnAfterCreated
public override void OnAfterCreated(EnvDTE.DTE dteObject)
{
this.cboPackerEncoding.DataSource = System.Enum.GetNames(typeof(Dean.Edwards.ECMAScriptPacker.PackerEncoding));
this.cboPackerEncoding.Text = this.Settings.ChirpDeanEdwardsPackerEncoding.ToString();
this.chkFastDecode.Checked = this.Settings.ChirpDeanEdwardsPackerFastDecode;
this.chkSpecialChars.Checked = this.Settings.ChirpDeanEdwardsPackerSpecialChars;
}
示例10: TransformToJs
public static string TransformToJs(string fullFileName, string text, EnvDTE.ProjectItem projectItem)
{
string error = null;
try
{
Settings settings = Settings.Instance(fullFileName);
return CoffeeScript.compile(text, settings.CoffeeScriptOptions);
}
catch (Exception e)
{
Match match;
if (TaskList.Instance != null && (match = regexError.Match(e.Message)).Success)
{
TaskList.Instance.Add(
projectItem.ContainingProject,
Microsoft.VisualStudio.Shell.TaskErrorCategory.Error,
fullFileName,
match.Groups[2].Value.ToInt(1),
0,
match.Groups[1].Value);
}
else
{
error = e.Message;
}
return null;
}
}
示例11: AddTranslationDialog
public AddTranslationDialog(EnvDTE.Project pro)
{
project = pro;
//
// Required for Windows Form Designer support
//
InitializeComponent();
ShowInTaskbar = false;
this.langLabel.Text = SR.GetString("AddTranslationDialog_Language");
this.cancelButton.Text = SR.GetString(SR.Cancel);
this.okButton.Text = SR.GetString(SR.OK);
this.label1.Text = SR.GetString("AddTranslationDialog_FileName");
this.Text = SR.GetString("AddTranslationDialog_Title");
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
//if (SR.LanguageName == "ja")
//{
// this.cancelButton.Location = new System.Drawing.Point(188, 72);
// this.cancelButton.Size = new System.Drawing.Size(84, 24);
// this.okButton.Location = new System.Drawing.Point(100, 72);
// this.okButton.Size = new System.Drawing.Size(84, 24);
//}
this.KeyPress += new KeyPressEventHandler(this.AddTranslationDialog_KeyPress);
}
示例12: Execute
public void Execute(EnvDTE.vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
if (FmMain.DoDialog("") == DialogResult.OK)
{
(IDE.ApplicationObject.ActiveDocument.Selection as TextSelection).Text = FmMain.Code;
}
}
示例13: if
/// <summary>
/// Runs custom wizard logic when a project has finished generating
/// </summary>
void IWizard.ProjectFinishedGenerating(EnvDTE.Project project)
{
if (project != null) {
if (project.Name == "SolutionItemsContainer") {
PerformSolutionInitialization(project);
MoveSolutionItemsToLib(project);
}
else if (project.Name == "ToolsSolutionItemsContainer") {
MoveSolutionItemsToToolsLib(project);
}
else if (project.Name == "CrudScaffolding") {
Project movedProject = MoveProjectTo("\\tools\\", project, "Code Generation");
ExcludeProjectFromBuildProcess(movedProject);
}
else if (project.Name == "CrudScaffoldingForEnterpriseApp") {
Project movedProject = MoveProjectTo("\\tools\\", project, "Code Generation");
ExcludeProjectFromBuildProcess(movedProject);
}
else if (project.Name == GetSolutionName() + ".Tests") {
MoveProjectTo("\\tests\\", project);
}
else if (project.Name == GetSolutionName() + ".Web.Controllers" ||
project.Name == GetSolutionName() + ".ApplicationServices" ||
project.Name == GetSolutionName() + ".Core" ||
project.Name == GetSolutionName() + ".Data" ||
project.Name == GetSolutionName() + ".Web") {
Project movedProject = MoveProjectTo("\\app\\", project);
// Give the solution time to release the lock on the project file
System.Threading.Thread.Sleep(MIN_TIME_FOR_PROJECT_TO_RELEASE_FILE_LOCK);
CaptureProjectGuidOf(movedProject);
}
}
}
示例14: FrmActivateMemoryContracts
public FrmActivateMemoryContracts(EnvDTE.Projects projects, string contractsAssemblyPath)
{
InitializeComponent();
this.projects = projects;
this.contractsAssemblyPath = contractsAssemblyPath;
}
示例15: GetSiblings
private static IEnumerable<EnvDTE.ProjectItem> GetSiblings(EnvDTE.ProjectItem item)
{
EnvDTE.ProjectItem folder = item.Collection.Parent as EnvDTE.ProjectItem;
List<EnvDTE.ProjectItem> items = new List<EnvDTE.ProjectItem>();
while (folder != null)
{
if (!folder.Kind.Equals(VSConstants.ItemTypeGuid.PhysicalFolder_string, System.StringComparison.OrdinalIgnoreCase))
{
folder = folder.Collection.Parent as EnvDTE.ProjectItem;
}
else
{
break;
}
}
if (folder != null)
{
items.AddRange(folder.ProjectItems.Cast<EnvDTE.ProjectItem>());
}
else if (item.ContainingProject != null && item.ContainingProject.ProjectItems != null)
{
items.AddRange(item.ContainingProject.ProjectItems.Cast<EnvDTE.ProjectItem>());
}
return items.Where(i => i.Kind.Equals(VSConstants.ItemTypeGuid.PhysicalFile_string, System.StringComparison.OrdinalIgnoreCase));
}