本文整理汇总了C#中Inside.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# Inside.HasFlag方法的具体用法?C# Inside.HasFlag怎么用?C# Inside.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inside
的用法示例。
在下文中一共展示了Inside.HasFlag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Push
public void Push(char ch)
{
if (readPreprocessorExpression) {
wordBuf.Append(ch);
}
if (inside.HasFlag(Inside.VerbatimString) && pc == '"' && ch != '"') {
inside &= ~Inside.StringLiteral;
}
switch (ch) {
case '#':
if (IsLineStart)
inside = Inside.PreProcessor;
break;
case '/':
if (IsInStringOrChar || IsInPreProcessorComment)
break;
if (pc == '/') {
if (inside.HasFlag(Inside.Comment)) {
inside |= Inside.DocComment;
} else {
inside |= Inside.Comment;
}
}
break;
case '*':
if (IsInStringOrChar || IsInComment || IsInPreProcessorComment)
break;
if (pc == '/')
inside |= Inside.MultiLineComment;
break;
case ' ':
currentIndent.Append(' ');
break;
case '\t':
var nextTabStop = (col - 1 + textEditorOptions.IndentSize) / textEditorOptions.IndentSize;
col = 1 + nextTabStop * textEditorOptions.IndentSize;
currentIndent.Append('\t');
offset++;
return;
case '\r':
if (readPreprocessorExpression) {
if (!eval(wordBuf.ToString()))
inside |= Inside.PreProcessorComment;
}
inside &= ~(Inside.Comment | Inside.String | Inside.CharLiteral | Inside.PreProcessor);
CheckKeyword(wordBuf.ToString());
wordBuf.Length = 0;
indent.Push(indentDelta);
indentDelta = new Indent(textEditorOptions);
if (addContinuation) {
indent.Push(IndentType.Continuation);
}
thisLineindent = indent.Clone();
addContinuation = false;
IsLineStart = true;
readPreprocessorExpression = false;
col = 1;
line++;
currentIndent.Length = 0;
break;
case '\n':
if (pc == '\r')
break;
goto case '\r';
case '"':
if (IsInComment || IsInPreProcessorComment)
break;
if (inside.HasFlag(Inside.StringLiteral)) {
if (pc != '\\')
inside &= ~Inside.StringLiteral;
break;
}
if (pc == '@') {
inside |= Inside.VerbatimString;
} else {
inside |= Inside.StringLiteral;
}
break;
case '<':
case '[':
case '(':
if (IsInComment || IsInStringOrChar || IsInPreProcessorComment)
break;
parenStack.Push(new TextLocation(line, col));
popNextParenBlock = true;
indent.Push(IndentType.Block);
break;
case '>':
case ']':
case ')':
if (IsInComment || IsInStringOrChar || IsInPreProcessorComment)
break;
if (popNextParenBlock && parenStack.Count > 0)
parenStack.Pop();
if (indent.Count > 0)
//.........这里部分代码省略.........
示例2: Push
public void Push(Inside inside, string keyword, int lineNum, int numSpaces)
{
StringBuilder indentBuilder;
int sp = size - 1;
Node node;
int n = 0;
indentBuilder = new StringBuilder();
if((inside & (Inside.Attribute | Inside.ParenList)) != 0){
if(size > 0 && stack[sp].inside == inside){
while(sp >= 0) {
if(stack[sp].inside.HasFlag(Inside.FoldedOrBlock))
break;
sp--;
}
if(sp >= 0){
indentBuilder.Append(stack[sp].indent);
if(stack[sp].line_num == lineNum)
n = stack[sp].num_spaces;
}
}else{
while(sp >= 0){
if(stack[sp].inside.HasFlag(Inside.FoldedBlockOrCase)){
indentBuilder.Append(stack[sp].indent);
break;
}
sp--;
}
}
if(numSpaces - n <= 0){
indentBuilder.Append('\t');
}else{
indentBuilder.Append(' ', numSpaces - n);
}
}else if(inside == Inside.MultiLineComment) {
if(size > 0){
indentBuilder.Append(stack[sp].indent);
if(stack[sp].line_num == lineNum)
n = stack[sp].num_spaces;
}
indentBuilder.Append(' ', numSpaces - n);
}else if(inside == Inside.Case) {
while(sp >= 0){
if((stack[sp].inside & Inside.FoldedOrBlock) != 0){
indentBuilder.Append(stack[sp].indent);
break;
}
sp--;
}
//if(engine.policy.IndentSwitchBody)
// indentBuilder.Append ('\t');
numSpaces = 0;
}else if(inside.HasFlag(Inside.FoldedOrBlock)){
while(sp >= 0){
if(stack[sp].inside.HasFlag(Inside.FoldedBlockOrCase)){
indentBuilder.Append(stack[sp].indent);
break;
}
sp--;
}
Inside parent = size > 0 ? stack[size - 1].inside : Inside.Empty;
// This is a workaround to make anonymous methods indent nicely
if (parent == Inside.ParenList)
stack[size - 1].indent = indentBuilder.ToString ();
if (inside == Inside.FoldedStatement) {
indentBuilder.Append ('\t');
} else if (inside == Inside.Block) {
if (parent != Inside.Case || numSpaces != -1)
indentBuilder.Append ('\t');
}
numSpaces = 0;
} else if (inside.HasFlag(Inside.StringOrChar)) {
// if these fold, do not indent
numSpaces = 0;
//pop regions back out
if (keyword == "region" || keyword == "endregion") {
for (; sp >= 0; sp--) {
if ((stack[sp].inside & Inside.FoldedBlockOrCase) != 0) {
indentBuilder.Append (stack[sp].indent);
break;
}
}
}
} else if (inside == Inside.LineComment || inside == Inside.DocComment) {
// can't actually fold, but we still want to push it onto the stack
numSpaces = 0;
} else {
// not a valid argument?
//.........这里部分代码省略.........