本文整理汇总了C#中BraceStyle类的典型用法代码示例。如果您正苦于以下问题:C# BraceStyle类的具体用法?C# BraceStyle怎么用?C# BraceStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BraceStyle类属于命名空间,在下文中一共展示了BraceStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:JerreS,项目名称:AbstractCode,代码行数:28,代码来源:TextOutputFormatter.cs
示例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 ();
}
}
开发者ID:holmak,项目名称:NRefactory,代码行数:26,代码来源:TextWriterOutputFormatter.cs
示例3: CloseBrace
public void CloseBrace(BraceStyle style)
{
Unindent();
WriteIndentation();
Write("}");
}
开发者ID:GunioRobot,项目名称:sdb-cli,代码行数:7,代码来源:DecompilerFormatter.cs
示例4: OpenBrace
public void OpenBrace(BraceStyle style)
{
WriteIndentation();
textWriter.Write(' ');
textWriter.Write('{');
Indent();
NewLine();
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:8,代码来源:TextWriterOutputFormatter.cs
示例5: CloseBrace
public void CloseBrace(BraceStyle style)
{
output.Unindent();
output.Write('}');
if (nodeStack.OfType<BlockStatement>().Count() <= 1)
output.MarkFoldEnd();
if (braceLevelWithinType >= 0)
braceLevelWithinType--;
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:9,代码来源:TextOutputFormatter.cs
示例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();
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:11,代码来源:TextOutputFormatter.cs
示例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--;
}
开发者ID:damnya,项目名称:dnSpy,代码行数:11,代码来源:TextTokenWriter.cs
示例8: OpenBrace
public void OpenBrace(BraceStyle style)
{
if (!_firstBrace)
NewLine();
else
_firstBrace = false;
WriteIndentation();
Write("{");
Indent();
NewLine();
}
开发者ID:GunioRobot,项目名称:sdb-cli,代码行数:14,代码来源:DecompilerFormatter.cs
示例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);
}
开发者ID:XQuantumForceX,项目名称:Reflexil,代码行数:46,代码来源:OutputFormatter.cs
示例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();
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:41,代码来源:TextWriterOutputFormatter.cs
示例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;
}
开发者ID:JerreS,项目名称:AbstractCode,代码行数:21,代码来源:TextOutputFormatter.cs
示例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;
}
}
开发者ID:segaman,项目名称:NRefactory,代码行数:17,代码来源:CSharpIndentEngine.cs
示例13: OpenBrace
void OpenBrace(BraceStyle style)
{
WriteSpecialsUpToRole(Roles.LBrace);
formatter.OpenBrace(style);
lastWritten = LastWritten.Other;
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:6,代码来源:CSharpOutputVisitor.cs
示例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;
}
}
开发者ID:segaman,项目名称:NRefactory,代码行数:27,代码来源:FormattingVisitor.cs
示例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;
}
}
开发者ID:segaman,项目名称:NRefactory,代码行数:66,代码来源:FormattingVisitor.cs
示例16: FixEmbeddedStatment
void FixEmbeddedStatment(BraceStyle braceStyle, BraceForcement braceForcement, CSharpTokenNode token, bool allowInLine, AstNode node, bool statementAlreadyIndented = false)
{
if (node == null) {
return;
}
bool isBlock = node is BlockStatement;
TextReplaceAction beginBraceAction = null;
TextReplaceAction endBraceAction = null;
switch (braceForcement) {
case BraceForcement.DoNotChange:
//nothing
break;
case BraceForcement.AddBraces:
if (!isBlock) {
AstNode n = node.Parent.GetCSharpNodeBefore(node);
int start = document.GetOffset(n.EndLocation);
string startBrace = "";
switch (braceStyle) {
case BraceStyle.EndOfLineWithoutSpace:
startBrace = "{";
break;
case BraceStyle.BannerStyle:
case BraceStyle.EndOfLine:
startBrace = " {";
break;
case BraceStyle.NextLine:
startBrace = this.options.EolMarker + curIndent.IndentString + "{";
break;
case BraceStyle.NextLineShifted2:
case BraceStyle.NextLineShifted:
curIndent.Push(IndentType.Block);
startBrace = this.options.EolMarker + curIndent.IndentString + "{";
curIndent.Pop();
break;
}
beginBraceAction = AddChange(start, 0, startBrace);
}
break;
case BraceForcement.RemoveBraces:
if (isBlock) {
BlockStatement block = node as BlockStatement;
if (block.Statements.Count() == 1) {
int offset1 = document.GetOffset(node.StartLocation);
int start = SearchWhitespaceStart(offset1);
int offset2 = document.GetOffset(node.EndLocation);
int end = SearchWhitespaceStart(offset2 - 1);
beginBraceAction = AddChange(start, offset1 - start + 1, null);
endBraceAction = AddChange(end + 1, offset2 - end, null);
node = block.FirstChild;
isBlock = false;
}
}
break;
}
if (isBlock) {
BlockStatement block = node as BlockStatement;
if (allowInLine && block.StartLocation.Line == block.EndLocation.Line && block.Statements.Count() <= 1) {
if (block.Statements.Count() == 1) {
nextStatementIndent = " ";
}
} else {
if (!statementAlreadyIndented) {
EnforceBraceStyle(braceStyle, block.LBraceToken, block.RBraceToken);
}
}
if (braceStyle == BraceStyle.NextLineShifted2) {
curIndent.Push(IndentType.Block);
}
} else {
if (allowInLine && token.StartLocation.Line == node.EndLocation.Line) {
nextStatementIndent = " ";
}
}
if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) {
curIndent.Push(IndentType.Block);
}
if (isBlock) {
VisitBlockWithoutFixingBraces((BlockStatement)node, false);
} else {
if (!statementAlreadyIndented) {
FixStatementIndentation(node.StartLocation);
}
node.AcceptVisitor(this);
}
if (policy.IndentBlocks && !(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement || policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement)) {
curIndent.Pop();
}
switch (braceForcement) {
case BraceForcement.DoNotChange:
break;
case BraceForcement.AddBraces:
if (!isBlock) {
int offset = document.GetOffset(node.EndLocation);
if (!char.IsWhiteSpace(document.GetCharAt(offset))) {
offset++;
}
string startBrace = "";
//.........这里部分代码省略.........
开发者ID:txdv,项目名称:monodevelop,代码行数:101,代码来源:AstFormattingVisitor.cs
示例17: CloseBrace
void CloseBrace(BraceStyle style)
{
switch (style) {
case BraceStyle.DoNotChange:
case BraceStyle.EndOfLine:
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine:
writer.Unindent();
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
break;
case BraceStyle.BannerStyle:
case BraceStyle.NextLineShifted:
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
writer.Unindent();
break;
case BraceStyle.NextLineShifted2:
writer.Unindent();
writer.WriteToken(Roles.RBrace, "}");
isAtStartOfLine = false;
writer.Unindent();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
开发者ID:jeremiahyan,项目名称:ILSpy,代码行数:27,代码来源:CSharpOutputVisitor.cs
示例18: WriteBlock
/// <summary>
/// Writes a block statement.
/// Similar to VisitBlockStatement() except that:
/// 1) it allows customizing the BraceStyle
/// 2) it does not write a trailing newline after the '}' (this job is left to the caller)
/// </summary>
protected virtual void WriteBlock(BlockStatement blockStatement, BraceStyle style)
{
StartNode(blockStatement);
OpenBrace(style);
foreach (var node in blockStatement.Statements) {
node.AcceptVisitor(this);
}
EndNode(blockStatement);
CloseBrace(style);
}
开发者ID:icsharpcode,项目名称:NRefactory,代码行数:16,代码来源:CSharpOutputVisitor.cs
示例19: AppendBraceEnd
void AppendBraceEnd (StringBuilder result, BraceStyle braceStyle)
{
switch (braceStyle) {
case BraceStyle.EndOfLineWithoutSpace:
case BraceStyle.NextLine:
case BraceStyle.EndOfLine:
IndentLevel --;
AppendIndent (result);
result.Append ("}");
break;
case BraceStyle.BannerStyle:
case BraceStyle.NextLineShifted:
AppendIndent (result);
result.Append ("}");
IndentLevel--;
break;
case BraceStyle.NextLineShifted2:
IndentLevel--;
AppendIndent (result);
result.Append ("}");
IndentLevel--;
break;
default:
goto case BraceStyle.NextLine;
}
}
开发者ID:ConorMurph1991,项目名称:monodevelop,代码行数:26,代码来源:CSharpCodeGenerator.cs
示例20: CloseBrace
void CloseBrace(BraceStyle style)
{
braceCounter--;
lastIsNewLine = false;
WriteLine();
switch (style)
{
case BraceStyle.Array:
Write(']');
break;
case BraceStyle.Object:
Write('}');
break;
default:
throw new Exception("Unknowed Brace Syyle");
}
}
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:17,代码来源:MyJson.cs
注:本文中的BraceStyle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论