本文整理汇总了C#中BraceStyle类的典型用法代码示例。如果您正苦于以下问题:C# BraceStyle类的具体用法?C# BraceStyle怎么用?C# BraceStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BraceStyle类属于命名空间,在下文中一共展示了BraceStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OpenBrace
public virtual void OpenBrace(BraceStyle style)
{
if (!_startOfLine)
{
switch (style)
{
case BraceStyle.EndOfLineNoSpacing:
break;
case BraceStyle.EndOfLine:
WriteSpace();
break;
case BraceStyle.NextLine:
WriteLine();
break;
case BraceStyle.NextLineIndented:
WriteLine();
Indent();
break;
}
}
Output.Write('{');
Indent();
WriteLine();
}
示例2: CloseBrace
public void CloseBrace(BraceStyle style)
{
switch (style) {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine:
Unindent();
WriteIndentation();
textWriter.Write('}');
break;
case BraceStyle.NextLineShifted:
WriteIndentation();
textWriter.Write('}');
Unindent();
break;
case BraceStyle.NextLineShifted2:
Unindent();
WriteIndentation();
textWriter.Write('}');
Unindent();
break;
default:
throw new ArgumentOutOfRangeException ();
}
}
示例3: CloseBrace
public void CloseBrace(BraceStyle style)
{
Unindent();
WriteIndentation();
Write("}");
}
示例4: OpenBrace
public void OpenBrace(BraceStyle style)
{
WriteIndentation();
textWriter.Write(' ');
textWriter.Write('{');
Indent();
NewLine();
}
示例5: CloseBrace
public void CloseBrace(BraceStyle style)
{
output.Unindent();
output.Write('}');
if (nodeStack.OfType<BlockStatement>().Count() <= 1)
output.MarkFoldEnd();
if (braceLevelWithinType >= 0)
braceLevelWithinType--;
}
示例6: OpenBrace
public void OpenBrace(BraceStyle style)
{
if (braceLevelWithinType >= 0 || nodeStack.Peek() is TypeDeclaration)
braceLevelWithinType++;
if (nodeStack.OfType<BlockStatement>().Count() <= 1) {
output.MarkFoldStart(defaultCollapsed: braceLevelWithinType == 1);
}
output.WriteLine();
output.WriteLine("{");
output.Indent();
}
示例7: CloseBrace
public void CloseBrace(BraceStyle style, out TextLocation? start, out TextLocation? end)
{
output.Unindent();
start = output.Location;
output.WriteRightBrace();
end = output.Location;
if (nodeStack.OfType<BlockStatement>().Count() <= 1)
output.MarkFoldEnd();
if (braceLevelWithinType >= 0)
braceLevelWithinType--;
}
示例8: OpenBrace
public void OpenBrace(BraceStyle style)
{
if (!_firstBrace)
NewLine();
else
_firstBrace = false;
WriteIndentation();
Write("{");
Indent();
NewLine();
}
示例9: BeginBrace
public void BeginBrace(BraceStyle style, bool indent)
{
switch (style) {
case BraceStyle.EndOfLine:
if (!LastCharacterIsWhiteSpace) {
Space();
}
PrintToken(Tokens.OpenCurlyBrace);
NewLine();
if (indent)
++IndentationLevel;
break;
case BraceStyle.EndOfLineWithoutSpace:
PrintToken(Tokens.OpenCurlyBrace);
NewLine();
if (indent)
++IndentationLevel;
break;
case BraceStyle.NextLine:
NewLine();
Indent();
PrintToken(Tokens.OpenCurlyBrace);
NewLine();
if (indent)
++IndentationLevel;
break;
case BraceStyle.NextLineShifted:
NewLine();
if (indent)
++IndentationLevel;
Indent();
PrintToken(Tokens.OpenCurlyBrace);
NewLine();
break;
case BraceStyle.NextLineShifted2:
NewLine();
if (indent)
++IndentationLevel;
Indent();
PrintToken(Tokens.OpenCurlyBrace);
NewLine();
++IndentationLevel;
break;
}
braceStack.Push(style);
}
示例10: OpenBrace
public void OpenBrace(BraceStyle style)
{
switch (style) {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.BannerStyle:
WriteIndentation();
if (!isAtStartOfLine)
textWriter.Write(' ');
textWriter.Write('{');
break;
case BraceStyle.EndOfLineWithoutSpace:
WriteIndentation();
textWriter.Write('{');
break;
case BraceStyle.NextLine:
if (!isAtStartOfLine)
NewLine();
WriteIndentation();
textWriter.Write('{');
break;
case BraceStyle.NextLineShifted:
NewLine ();
Indent();
WriteIndentation();
textWriter.Write('{');
NewLine();
return;
case BraceStyle.NextLineShifted2:
NewLine ();
Indent();
WriteIndentation();
textWriter.Write('{');
break;
default:
throw new ArgumentOutOfRangeException ();
}
Indent();
NewLine();
}
示例11: CloseBrace
public virtual void CloseBrace(BraceStyle style)
{
Unindent();
if (!_startOfLine)
{
switch (style)
{
case BraceStyle.EndOfLine:
WriteSpace();
break;
case BraceStyle.NextLine:
WriteLine();
break;
}
}
Output.Write('}');
_startOfLine = false;
}
示例12: AddIndentation
void AddIndentation(BraceStyle braceStyle)
{
switch (braceStyle) {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine:
case BraceStyle.NextLineShifted:
case BraceStyle.BannerStyle:
indentDelta.Push(IndentType.Block);
break;
case BraceStyle.NextLineShifted2:
indentDelta.Push(IndentType.DoubleBlock);
break;
}
}
示例13: OpenBrace
void OpenBrace(BraceStyle style)
{
WriteSpecialsUpToRole(Roles.LBrace);
formatter.OpenBrace(style);
lastWritten = LastWritten.Other;
}
示例14: FixClosingBrace
void FixClosingBrace(BraceStyle braceStyle, AstNode rbrace)
{
if (rbrace.IsNull)
return;
switch (braceStyle) {
case BraceStyle.DoNotChange:
return;
case BraceStyle.NextLineShifted:
case BraceStyle.BannerStyle:
curIndent.Push(IndentType.Block);
CorrectClosingBrace (rbrace);
curIndent.Pop ();
break;
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.EndOfLine:
case BraceStyle.NextLine:
CorrectClosingBrace (rbrace);
break;
case BraceStyle.NextLineShifted2:
curIndent.Push(IndentType.Block);
CorrectClosingBrace (rbrace);
curIndent.Pop ();
break;
}
}
示例15: FixOpenBrace
void FixOpenBrace(BraceStyle braceStyle, AstNode lbrace)
{
if (lbrace.IsNull)
return;
switch (braceStyle) {
case BraceStyle.DoNotChange:
return;
case BraceStyle.BannerStyle:
case BraceStyle.EndOfLine:
var prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
int prevOffset = document.GetOffset(prev.EndLocation);
if (prev is Comment || prev is PreProcessorDirective) {
int next = document.GetOffset(lbrace.GetNextNode ().StartLocation);
AddChange(prevOffset, next - prevOffset, "");
while (prev is Comment || prev is PreProcessorDirective)
prev = prev.GetPrevNode();
prevOffset = document.GetOffset(prev.EndLocation);
AddChange(prevOffset, 0, " {");
} else {
int braceOffset2 = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset2 - prevOffset, " ");
}
break;
case BraceStyle.EndOfLineWithoutSpace:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
int braceOffset = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset - prevOffset, "");
break;
case BraceStyle.NextLine:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
break;
case BraceStyle.NextLineShifted:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
curIndent.Push(IndentType.Block);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
curIndent.Pop();
break;
case BraceStyle.NextLineShifted2:
prev = lbrace.GetPrevNode (NoWhitespacePredicate);
if (prev is PreProcessorDirective)
return;
prevOffset = document.GetOffset(prev.EndLocation);
braceOffset = document.GetOffset(lbrace.StartLocation);
curIndent.Push(IndentType.Block);
AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
curIndent.Pop();
break;
}
}