本文整理汇总了C#中MonoDevelop.Refactoring.RefactoringOptions.GetIndent方法的典型用法代码示例。如果您正苦于以下问题:C# RefactoringOptions.GetIndent方法的具体用法?C# RefactoringOptions.GetIndent怎么用?C# RefactoringOptions.GetIndent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Refactoring.RefactoringOptions
的用法示例。
在下文中一共展示了RefactoringOptions.GetIndent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateMethodDeclaration
static string GenerateMethodDeclaration (RefactoringOptions options, ExtractMethodParameters param)
{
StringBuilder methodText = new StringBuilder ();
string indent = options.GetIndent (param.DeclaringMember);
if (param.InsertionPoint != null) {
switch (param.InsertionPoint.LineBefore) {
case NewLineInsertion.Eol:
methodText.AppendLine ();
break;
case NewLineInsertion.BlankLine:
methodText.Append (indent);
methodText.AppendLine ();
break;
}
} else {
methodText.AppendLine ();
methodText.Append (indent);
methodText.AppendLine ();
}
var codeGenerator = new CSharpCodeGenerator () {
UseSpaceIndent = options.Document.Editor.Options.TabsToSpaces,
EolMarker = options.Document.Editor.EolMarker,
TabSize = options.Document.Editor.Options.TabSize
};
var newMethod = GenerateMethodStub (options, param);
IType callingType = null;
var cu = options.Document.CompilationUnit;
if (cu != null)
callingType = newMethod.DeclaringType = options.Document.CompilationUnit.GetTypeAt (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column);
var createdMethod = codeGenerator.CreateMemberImplementation (callingType, newMethod, false);
if (param.GenerateComment && DocGenerator.Instance != null)
methodText.AppendLine (DocGenerator.Instance.GenerateDocumentation (newMethod, indent + "/// "));
string code = createdMethod.Code;
int idx1 = code.LastIndexOf ("throw");
int idx2 = code.LastIndexOf (";");
methodText.Append (code.Substring (0, idx1));
if (param.Nodes != null && (param.Nodes.Count == 1 && param.Nodes[0].NodeType == NodeType.Expression)) {
methodText.Append ("return ");
methodText.Append (param.Text.Trim ());
methodText.Append (";");
} else {
StringBuilder text = new StringBuilder ();
if (param.OneChangedVariable) {
var par = param.Variables.First (p => p.IsDefinedInsideCutRegion && p.UsedAfterCutRegion);
if (!par.UsedInCutRegion) {
text.Append (new CSharpAmbience ().GetString (par.ReturnType, OutputFlags.ClassBrowserEntries));
text.Append (" ");
text.Append (par.Name);
text.AppendLine (";");
}
}
text.Append (param.Text);
if (param.OneChangedVariable) {
text.AppendLine ();
text.Append ("return ");
text.Append (param.Variables.First (p => p.IsDefinedInsideCutRegion && p.UsedAfterCutRegion).Name);
text.Append (";");
}
methodText.Append (AddIndent (text.ToString (), indent + "\t"));
}
methodText.Append (code.Substring (idx2 + 1));
if (param.InsertionPoint != null) {
switch (param.InsertionPoint.LineAfter) {
case NewLineInsertion.Eol:
methodText.AppendLine ();
break;
case NewLineInsertion.BlankLine:
methodText.AppendLine ();
methodText.Append (indent);
methodText.AppendLine ();
break;
case NewLineInsertion.None:
methodText.AppendLine ();
break;
}
} else {
methodText.AppendLine ();
methodText.Append (indent);
methodText.AppendLine ();
}
return methodText.ToString ();
}