本文整理汇总了C#中ProjectItem.AddLine方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.AddLine方法的具体用法?C# ProjectItem.AddLine怎么用?C# ProjectItem.AddLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectItem
的用法示例。
在下文中一共展示了ProjectItem.AddLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 { }
}
}