本文整理汇总了C#中ProjectItem类的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem类的具体用法?C# ProjectItem怎么用?C# ProjectItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectItem类属于命名空间,在下文中一共展示了ProjectItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateNewProcessOverview
public static void CreateNewProcessOverview(string ProcessName, ProjectItem processFile, ProjectItem diagramFile)
{
var store = new Store(typeof(CloudCoreArchitectProcessOverviewDomainModel));
var partition = new Partition(store);
var result = new SerializationResult();
using (Transaction t = store.TransactionManager.BeginTransaction("create new process overview model"))
{
try
{
var processOverviewSerializationHelper = CloudCoreArchitectProcessOverviewSerializationHelper.Instance;
Architect.ProcessOverview.Process process = processOverviewSerializationHelper.CreateModelHelper(partition);
SetProcessOverviewProperties(ProcessName, process);
var diagram = processOverviewSerializationHelper.CreateDiagramHelper(partition, process);
processOverviewSerializationHelper.SaveModelAndDiagram(result, process, processFile.FileNames[0], diagram, diagramFile.FileNames[0]);
AddAssemblyReference(ProcessName, process);
t.Commit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
示例2: RemoveSubItemsAndAssociatedFiles
public static void RemoveSubItemsAndAssociatedFiles(ProjectItem parentItem)
{
if (parentItem == null) return;
var projectItems = parentItem.ProjectItems.Cast<ProjectItem>();
RemoveSubItemsAndAssociatedFiles(projectItems);
}
示例3: VisitClass
protected override void VisitClass(CodeClass codeClass)
{
if (codeClass.FullName == _classFullName)
{
_result = codeClass.ProjectItem;
}
}
示例4: ContainsDeployableItem
private bool ContainsDeployableItem(ProjectItem pitem)
{
if (pitem != null && pitem.ProjectItems != null)
{
foreach (ProjectItem childItem in pitem.ProjectItems)
{
if (childItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile)
{
//ok, is file
if (ItemIsDeployable(childItem))
{
return true;
}
}
else
{
if (ContainsDeployableItem(childItem))
{
return true;
}
}
}
}
return false;
}
示例5: CreateFileCodeModel
public static FileCodeModel CreateFileCodeModel(DTE dte, ProjectItem item, CodeDomProvider provider, string fileName)
{
if (null == item) {
throw new ArgumentNullException("item");
}
return new CodeDomFileCodeModel(dte, item, provider, fileName);
}
示例6: ProjectItemRelationship
public ProjectItemRelationship (ProjectItem parentProjectItem, MD.ProjectItem msbuildProjectItem)
{
this.ParentProjectItem = parentProjectItem;
this.MSBuildProjectItem = msbuildProjectItem;
this.Project = (Project)parentProjectItem.ContainingProject;
GetRelationship ();
}
示例7: RunFeatures
public bool RunFeatures(ProjectItem projectItem, bool debug)
{
if (IsAllowDebugGeneratedFilesSet(projectItem))
return runnerGateway_CodeBehind.RunFeatures(projectItem, debug);
return runnerGateway_TestWindowInvoke.RunFeatures(projectItem, debug);
}
示例8: Edit
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var user = db.UserModels
.Include("UserProjectRoles")
.Include("UserProjectRoles.Role")
.Where(m => m.Id == id).ToList().First();
var userProjectsList = user.UserProjectRoles.ToList();
var projectList = db.Projects.ToList();
var viewmodel = new UserViewModel();
viewmodel.Id = user.Id;
viewmodel.Email = user.Email;
viewmodel.FirstName = user.FirstName;
viewmodel.LastName = user.LastName;
viewmodel.IsAdmin = user.Admin;
foreach (var item in projectList)
{
var toAdd = new ProjectItem();
toAdd.ProjectId = item.Id;
toAdd.ProjectName = item.Name;
toAdd.IsManager = userProjectsList.Where(m => m.ProjectId == item.Id && m.Role.Role1 == "Manager").ToList().Count > 0;
toAdd.IsDeveloper = userProjectsList.Where(m => m.ProjectId == item.Id && m.Role.Role1 == "Developer").ToList().Count > 0;
toAdd.IsSubmitter = userProjectsList.Where(m => m.ProjectId == item.Id && m.Role.Role1 == "Submitter").ToList().Count > 0;
viewmodel.ProjectItems.Add(toAdd);
}
return View(viewmodel);
}
示例9: CodeDomFileCodeModel
private CodeDomCodeNamespace vsTopNamespace; // top-level CodeModel namespace
#endregion Fields
#region Constructors
public CodeDomFileCodeModel(DTE dte, ProjectItem parent, CodeDomProvider provider, string filename)
: base(dte, filename)
{
this.parent = parent;
this.provider = provider as IMergableProvider;
if (provider == null) throw new ArgumentException("provider must implement IMergeableProvider interface");
}
示例10: ProcessFile
internal static IEnumerable<IntellisenseObject> ProcessFile(ProjectItem item, HashSet<CodeClass> underProcess = null)
{
if (item.FileCodeModel == null)
return null;
List<IntellisenseObject> list = new List<IntellisenseObject>();
if (underProcess == null)
underProcess = new HashSet<CodeClass>();
foreach (CodeElement element in item.FileCodeModel.CodeElements)
{
if (element.Kind == vsCMElement.vsCMElementNamespace)
{
CodeNamespace cn = (CodeNamespace)element;
foreach (CodeElement member in cn.Members)
{
if (ShouldProcess(member))
ProcessElement(member, list, underProcess);
}
}
else if (ShouldProcess(element))
ProcessElement(element, list, underProcess);
}
return new HashSet<IntellisenseObject>(list);
}
示例11: VSProjectItemManager
internal VSProjectItemManager(DTE2 dte, ProjectItem projectItem, string fileNamePrefix)
{
this.dte = dte;
this.projectItem = projectItem;
this.filesAdded = new Dictionary<string, object>();
this.filesCreated = new List<string>();
if (this.projectItem != null)
{
if (string.IsNullOrEmpty(fileNamePrefix))
{
fileNamePrefix = this.GetFileNamePrefix(projectItem.Name);
}
if (projectItem.FileCount > 0)
{
try
{
this.fullFileNamePrefix = Path.GetDirectoryName(projectItem.get_FileNames(0)) + @"\" + fileNamePrefix;
}
catch (System.ArgumentException)
{
//vs.Php raise exception
}
}
}
}
示例12: InternalExecute
public static void InternalExecute(ProjectItem projectItem)
{
var ctors = new List<CodeFunction>();
foreach (CodeFunction constructor in projectItem.FindContructors().Where(m => m.Parameters.Count > 0))
{
var codeElement = constructor.As<CodeElement>();
string ctorText = codeElement.InnerText();
var editPoint = codeElement.AtTheFirstLineAfterTheOpeningBrakect();
bool lineAdded = false;
foreach (var param in constructor.Parameters().Reverse())
{
if (param.Type.CodeType.Kind != vsCMElement.vsCMElementStruct && !ctorText.Contains($"ArgumentNullException(\"{param.Name}\")"))
{
lineAdded = true;
projectItem.AddLine(editPoint, param.Name.ToCtorNullCheck());
}
}
if (lineAdded)
{
ctors.Add(constructor);
}
}
if (ctors.Any())
{
if (!projectItem.Contains("using System;"))
{
projectItem.AddLine(projectItem.FindNameSpace().As<CodeElement>().AtTheFirstLineAfterTheOpeningBrakect(), "using System;");
}
}
foreach (CodeFunction constructor in projectItem.FindContructors().Where(m => m.Parameters.Count > 0))
{
if (string.IsNullOrWhiteSpace(constructor.DocComment))
{
AddCommentsToCodeElements.AddDocCommentToCtor(constructor);
}
var docComment = constructor.DocComment;
var codeElement = constructor.As<CodeElement>();
if ((codeElement.Contains("throw new ArgumentNullException") || codeElement.Contains("throw new System.ArgumentNullException"))
&& (!docComment.Contains(exceptionMessage1) && !docComment.Contains(exceptionMessage2)))
{
codeElement.AppendToDocComment(exceptionMessage1);
}
}
if (ctors.Any())
{
var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
try
{
dte.ExecuteCommand("Edit.FormatDocument");
}
catch { }
}
}
示例13: AddCustomToolItemBeforeQueryStatus
private void AddCustomToolItemBeforeQueryStatus(object sender, EventArgs e)
{
OleMenuCommand button = (OleMenuCommand) sender;
button.Visible = false;
UIHierarchyItem uiItem = GetSelectedItem();
if (uiItem == null)
return;
_item = uiItem.Object as ProjectItem;
if (_item == null)
return;
if (_item.ContainingProject.Kind != PrjKind.prjKindCSharpProject && _item.ContainingProject.Kind != PrjKind.prjKindVBProject)
return;
string fullPath = _item.Properties.Item("FullPath").Value.ToString();
string ext = Path.GetExtension(fullPath);
if (!ext.Equals(".vsct", StringComparison.OrdinalIgnoreCase))
return;
button.Checked = _item.Properties.Item("CustomTool").Value.ToString() == CUSTOM_TOOL_NAME;
button.Visible = true;
}
示例14: GetSelfAndChildProjectItems
public static IEnumerable<ProjectItem> GetSelfAndChildProjectItems(ProjectItem projectItem)
{
yield return projectItem;
for (int i = 1; i <= projectItem.ProjectItems.Count; i++)
{
ProjectItem item = null;
try
{
item = projectItem.ProjectItems.Item(i);
}
catch (Exception ex)
{
// sometimes we get System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
// when we open some file in the text editor
LogService.LogError(new Exception("Cannot evaluate items in the project!", ex));
}
if (item != null)
{
foreach (var childItem in GetSelfAndChildProjectItems(item))
{
yield return childItem;
}
}
}
}
示例15: ProcessConfigFile
/// <summary>
/// Loads XML from the .config file, manipulates it to possibly add an "defaultConnectionFactory" entry
/// and then attempts to save the file.
/// </summary>
/// <remarks>
/// If the file cannot be saved then it is not saved and an exception is thrown. Under normal use this should not happen
/// because NuGet will have ensured that the file is writable. It would be possible to try to do things like try check out
/// the file from source control, but it doesn't seem like this is valuable enough to implement given it will not normally be used.
/// </remarks>
public virtual void ProcessConfigFile(ProjectItem configItem, IEnumerable<Func<XDocument, bool>> manipulators)
{
Contract.Requires(configItem != null);
var fileName = configItem.FileNames[0];
var config = XDocument.Load(fileName);
var fileModified = false;
foreach (var manipulator in manipulators)
{
fileModified = manipulator(config) || fileModified;
}
if (fileModified)
{
try
{
config.Save(fileName);
}
catch (Exception ex)
{
throw new IOException(Strings.SaveConnectionFactoryInConfigFailed(fileName), ex);
}
}
}