本文整理汇总了C#中ProjectItem.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.Contains方法的具体用法?C# ProjectItem.Contains怎么用?C# ProjectItem.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectItem
的用法示例。
在下文中一共展示了ProjectItem.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 { }
}
}
示例2: Execute
public static void Execute(ProjectItem projectItem)
{
if (projectItem.Name.EndsWith(".config", StringComparison.CurrentCulture) && projectItem.Contains("<moduleConfiguration") && !projectItem.ContainingProject.IsTestProject())
{
var dte = (DTE)Package.GetGlobalService(typeof(SDTE));
string configFile = projectItem.ReadAllText();
var moduleConfig = configFile.Deserialize<XmlModuleConfig>();
if (moduleConfig != null)
{
var project = dte.Solution.FindProject(p => p.Name == moduleConfig.AssemblyName);
var moduleProjectItem = project.FindProjectItem(p => p.Name == moduleConfig.CsFileName);
string csFile = moduleProjectItem.ReadAllText();
string newConfig = DetermineNewConfig(configFile, csFile);
if (!(configFile.EqualsExcludingWhitespace(newConfig)))
{
projectItem.Document?.Activate();
projectItem.ClearAllText();
projectItem.SetText(newConfig);
}
}
}
}