本文整理汇总了C#中IFormatter.WriteKeyword方法的典型用法代码示例。如果您正苦于以下问题:C# IFormatter.WriteKeyword方法的具体用法?C# IFormatter.WriteKeyword怎么用?C# IFormatter.WriteKeyword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFormatter
的用法示例。
在下文中一共展示了IFormatter.WriteKeyword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLockStatement
private void WriteLockStatement(ILockStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("lock");
formatter.Write(" ");
formatter.Write("(");
this.WriteExpression(statement.Expression, formatter);
formatter.Write(")");
formatter.WriteLine();
formatter.WriteKeyword("begin");
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("end");
}
示例2: WriteVariableDeclaration
private void WriteVariableDeclaration(IVariableDeclaration variableDeclaration, IFormatter formatter)
{
formatter.WriteKeyword("var ");
this.WriteDeclaration(variableDeclaration.Name, formatter); // TODO Escape = true
if (!this.forLoop)
{
formatter.Write(";");
formatter.WriteLine();
}
}
示例3: WriteWhileStatement
private void WriteWhileStatement(IWhileStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("while");
formatter.Write(" ");
formatter.Write("(");
if (statement.Condition != null)
{
this.WriteExpression(statement.Condition, formatter);
}
else
formatter.WriteLiteral("true");
formatter.Write(")");
formatter.Write(" {");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.Write("}");
}
示例4: WriteTypeOfExpression
private void WriteTypeOfExpression(ITypeOfExpression expression, IFormatter formatter)
{
formatter.WriteKeyword("typeof");
formatter.Write("(");
this.WriteType(expression.Type, formatter);
formatter.Write(")");
}
示例5: WriteUsingStatement
private void WriteUsingStatement(IUsingStatement statement, IFormatter formatter)
{
IVariableReference variable = null;
IAssignExpression assignExpression = statement.Expression as IAssignExpression;
if (assignExpression != null)
{
IVariableDeclarationExpression variableDeclarationExpression = assignExpression.Target as IVariableDeclarationExpression;
if (variableDeclarationExpression != null)
{
variable = variableDeclarationExpression.Variable;
}
IVariableReferenceExpression variableReferenceExpression = assignExpression.Target as IVariableReferenceExpression;
if (variableReferenceExpression != null)
{
variable = variableReferenceExpression.Variable;
}
}
this.WriteStatementSeparator(formatter);
// make a comment that Reflector detected this as a using statement
//formatter.Write("{using");
if (variable != null)
{
//formatter.Write(" ");
this.WriteVariableReference(variable, formatter);
}
formatter.Write("}");
formatter.WriteLine();
// and replace this with
// - create obj
// - try ... finally obj.Dispose end
formatter.WriteKeyword("begin");
formatter.WriteLine();
formatter.WriteIndent();
if (variable != null)
{
this.WriteVariableReference(variable, formatter);
formatter.Write(" ");
formatter.WriteKeyword(":=");
formatter.Write(" ");
this.WriteExpression(assignExpression.Expression, formatter);
this.WriteStatementSeparator(formatter);
}
formatter.WriteKeyword("try");
formatter.WriteLine();
formatter.WriteIndent();
if (statement.Body != null)
{
this.WriteBlockStatement(statement.Body, formatter);
}
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("finally");
formatter.WriteLine();
formatter.WriteIndent();
if (variable != null)
{
this.firstStmt = true;
this.WriteVariableReference(variable, formatter);
formatter.Write(".");
formatter.Write("Dispose");
formatter.WriteLine();
}
else
{
this.firstStmt = true;
this.WriteExpression(statement.Expression);
formatter.Write(".");
formatter.Write("Dispose");
formatter.WriteLine();
}
formatter.WriteOutdent();
formatter.WriteKeyword("end");
formatter.WriteLine();
formatter.WriteOutdent();
formatter.WriteKeyword("end");
}
示例6: WriteTryCastExpression
private void WriteTryCastExpression(ITryCastExpression expression, IFormatter formatter)
{
formatter.Write("(");
this.WriteExpression(expression.Expression, formatter);
formatter.WriteKeyword(" as ");
this.WriteType(expression.TargetType, formatter);
formatter.Write(")");
}
示例7: WriteType
private void WriteType(IType type, IFormatter formatter)
{
ITypeReference typeReference = type as ITypeReference;
if (typeReference != null)
{
string description = Helper.GetNameWithResolutionScope(typeReference);
this.WriteTypeReference(typeReference, formatter, description, typeReference);
return;
}
IArrayType arrayType = type as IArrayType;
if (arrayType != null)
{
this.WriteType(arrayType.ElementType, formatter);
formatter.Write("[");
IArrayDimensionCollection dimensions = arrayType.Dimensions;
for (int i = 0; i < dimensions.Count; i++)
{
if (i != 0)
{
formatter.Write(",");
}
if ((dimensions[i].LowerBound != 0) && (dimensions[i].UpperBound != -1))
{
if ((dimensions[i].LowerBound != -1) || (dimensions[i].UpperBound != -1))
{
formatter.Write((dimensions[i].LowerBound != -1) ? dimensions[i].LowerBound.ToString(CultureInfo.InvariantCulture) : ".");
formatter.Write("..");
formatter.Write((dimensions[i].UpperBound != -1) ? dimensions[i].UpperBound.ToString(CultureInfo.InvariantCulture) : ".");
}
}
}
formatter.Write("]");
return;
}
IPointerType pointerType = type as IPointerType;
if (pointerType != null)
{
this.WriteType(pointerType.ElementType, formatter);
formatter.Write("*");
return;
}
IReferenceType referenceType = type as IReferenceType;
if (referenceType != null)
{
// formatter.WriteKeyword ("var"); // already done before the param name - HV
// formatter.Write (" ");
this.WriteType(referenceType.ElementType, formatter);
return;
}
IOptionalModifier optionalModifier = type as IOptionalModifier;
if (optionalModifier != null)
{
this.WriteType(optionalModifier.ElementType, formatter);
formatter.Write(" ");
formatter.WriteKeyword("modopt");
formatter.Write("(");
this.WriteType(optionalModifier.Modifier, formatter);
formatter.Write(")");
return;
}
IRequiredModifier requiredModifier = type as IRequiredModifier;
if (requiredModifier != null)
{
this.WriteType(requiredModifier.ElementType, formatter);
formatter.Write(" ");
formatter.WriteKeyword("modreq");
formatter.Write("(");
this.WriteType(requiredModifier.Modifier, formatter);
formatter.Write(")");
return;
}
IFunctionPointer functionPointer = type as IFunctionPointer;
if (functionPointer != null)
{
this.WriteType(functionPointer.ReturnType.Type, formatter);
formatter.Write(" *(");
for (int i = 0; i < functionPointer.Parameters.Count; i++)
{
if (i != 0)
{
formatter.Write(", ");
}
this.WriteType(functionPointer.Parameters[i].ParameterType, formatter);
}
formatter.Write(")");
return;
}
IGenericParameter genericParameter = type as IGenericParameter;
//.........这里部分代码省略.........
示例8: WriteMethodReturnStatement
private void WriteMethodReturnStatement(IMethodReturnStatement statement, IFormatter formatter, bool lastStatement)
{
this.WriteStatementSeparator(formatter);
if (statement.Expression == null)
{
formatter.WriteKeyword("return");
formatter.Write(";");
}
else
{
formatter.WriteKeyword("return");
formatter.Write(" ");
this.WriteExpression(statement.Expression, formatter);
formatter.Write(";");
}
}
示例9: WriteNullCoalescingExpression
private void WriteNullCoalescingExpression(INullCoalescingExpression value, IFormatter formatter)
{
formatter.Write("(");
this.WriteExpression(value.Condition, formatter);
formatter.Write("!!");
formatter.Write(" ");
formatter.WriteKeyword("?");
formatter.Write(" ");
this.WriteExpression(value.Condition, formatter);
formatter.Write(" ");
formatter.WriteKeyword(":");
formatter.Write(" ");
this.WriteExpression(value.Expression, formatter);
formatter.Write(")");
}
示例10: WriteMethodDirectives
private void WriteMethodDirectives(IMethodDeclaration methodDeclaration, IFormatter formatter)
{
ITypeDeclaration declaringType = (methodDeclaration.DeclaringType as ITypeReference).Resolve();
if (!declaringType.Interface)
{
formatter.Write(" ");
if (methodDeclaration.Static)
{
formatter.Write("static;");
formatter.Write(" ");
}
if ((methodDeclaration.Final) && (!methodDeclaration.NewSlot))
{
formatter.WriteKeyword("final;");
formatter.Write(" ");
}
if (methodDeclaration.Virtual)
{
if (methodDeclaration.Abstract)
{
formatter.WriteKeyword("abstract;");
formatter.Write(" ");
}
else if ((methodDeclaration.NewSlot) && (!methodDeclaration.Final))
{
formatter.WriteKeyword("virtual;");
formatter.Write(" ");
}
if (!methodDeclaration.NewSlot)
{
formatter.WriteKeyword("override;");
formatter.Write(" ");
}
}
}
}
示例11: WriteMethodOfExpression
private void WriteMethodOfExpression(IMethodOfExpression value, IFormatter formatter)
{
formatter.WriteKeyword("methodof");
formatter.Write("(");
this.WriteType(value.Method.DeclaringType, formatter);
formatter.Write(".");
formatter.WriteReference(value.Method.Name, this.GetMethodReferenceDescription(value.Method), value.Method);
if (value.Type != null)
{
formatter.Write(", ");
this.WriteType(value.Type, formatter);
}
formatter.Write(")");
}
示例12: WriteMethodAttributes
private void WriteMethodAttributes(IMethodDeclaration methodDeclaration, IFormatter formatter)
{
ITypeDeclaration declaringType = (methodDeclaration.DeclaringType as ITypeReference).Resolve();
if (!declaringType.Interface)
{
WriteMethodVisibility(methodDeclaration.Visibility, formatter);
if (methodDeclaration.Static)
{
formatter.WriteKeyword("class");
formatter.Write(" ");
}
}
}
示例13: WriteMemoryInitializeStatement
private void WriteMemoryInitializeStatement(IMemoryInitializeStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("meminit");
formatter.Write("(");
this.WriteExpression(statement.Offset, formatter);
formatter.Write(", ");
this.WriteExpression(statement.Value, formatter);
formatter.Write(", ");
this.WriteExpression(statement.Length, formatter);
formatter.Write(")");
}
示例14: WriteMemoryCopyStatement
private void WriteMemoryCopyStatement(IMemoryCopyStatement statement, IFormatter formatter)
{
this.WriteStatementSeparator(formatter);
formatter.WriteKeyword("memcpy");
formatter.Write("(");
this.WriteExpression(statement.Source, formatter);
formatter.Write(", ");
this.WriteExpression(statement.Destination, formatter);
formatter.Write(", ");
this.WriteExpression(statement.Length, formatter);
formatter.Write(")");
}
示例15: WriteThisReferenceExpression
private void WriteThisReferenceExpression(IThisReferenceExpression expression, IFormatter formatter)
{
formatter.WriteKeyword("this");
}