本文整理汇总了C#中ReturnStatement类的典型用法代码示例。如果您正苦于以下问题:C# ReturnStatement类的具体用法?C# ReturnStatement怎么用?C# ReturnStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReturnStatement类属于命名空间,在下文中一共展示了ReturnStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateCode
protected override string GenerateCode(ITypeDefinition currentClass)
{
// string[] fields = listBox.SelectedItems.OfType<PropertyOrFieldWrapper>().Select(f2 => f2.MemberName).ToArray();
string[] fields = parameterList.Where(f => f.IsIncluded).Select(f2 => f2.MemberName).ToArray();
PrimitiveExpression formatString = new PrimitiveExpression(GenerateFormatString(currentClass, editor.Language.CodeGenerator, fields));
List<Expression> param = new List<Expression>() { formatString };
ReturnStatement ret = new ReturnStatement(new InvocationExpression(
new MemberReferenceExpression(new TypeReferenceExpression(ConvertType(KnownTypeCode.String)), "Format"),
param.Concat(fields.Select(f => new IdentifierExpression(f))).ToList()
));
if (baseCallNode != null) {
MethodDeclaration insertedOverrideMethod = refactoringContext.GetNode().PrevSibling as MethodDeclaration;
if (insertedOverrideMethod == null) {
// We are not inside of a method declaration
return null;
}
using (Script script = refactoringContext.StartScript()) {
NewLineNode nextNewLineNode = insertedOverrideMethod.NextSibling as NewLineNode;
// Find base method call and replace it by return statement
script.AddTo(insertedOverrideMethod.Body, ret);
AppendNewLine(script, insertedOverrideMethod, nextNewLineNode);
}
}
return null;
}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:30,代码来源:OverrideToStringMethodDialog.xaml.cs
示例2: InsertAfterStatementIndentsLikeStatement
public void InsertAfterStatementIndentsLikeStatement()
{
var input [email protected]"
public class Test
{
void DoublyIndented()
{
System.Console.WriteLine(""hello"");
}
}";
var expected = @"
public class Test
{
void DoublyIndented()
{
System.Console.WriteLine(""hello"");
return;
}
}";
DoInsertAfterTest(input, expected, (syntaxTree, script) =>
{
var nodeToInsert = new ReturnStatement();
var nodeToInsertAfter = syntaxTree.DescendantsAndSelf.OfType<ExpressionStatement>().Single();
script.InsertAfter(nodeToInsertAfter,nodeToInsert);
});
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:27,代码来源:ScriptTests.cs
示例3: ReturnStatementProducesReturnWithValue
public void ReturnStatementProducesReturnWithValue()
{
var statement = new ReturnStatement(3);
Assert.AreEqual(3, statement.Value);
Assert.AreEqual("return 3;", statement.ToString());
statement.Value = "Yes!";
Assert.AreEqual("return \"Yes!\";", statement.ToString());
}
开发者ID:DaveVdE,项目名称:adamjsgenerator,代码行数:11,代码来源:ReturnStatementTests.cs
示例4: PostWalk
protected internal virtual void PostWalk(ReturnStatement node) { }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:1,代码来源:Walker.Generated.cs
示例5: Walk
// ReturnStatement
protected internal virtual bool Walk(ReturnStatement node) { return true; }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:2,代码来源:Walker.Generated.cs
示例6: Visit
public override object Visit (Return returnStatement)
{
var result = new ReturnStatement ();
result.AddChild (new CSharpTokenNode (Convert (returnStatement.loc), "return".Length), ReturnStatement.Roles.Keyword);
if (returnStatement.Expr != null)
result.AddChild ((INode)returnStatement.Expr.Accept (this), ReturnStatement.Roles.Expression);
var location = LocationsBag.GetLocations (returnStatement);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ReturnStatement.Roles.Semicolon);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:14,代码来源:CSharpParser.cs
示例7: VisitReturnStatement
public void VisitReturnStatement(ReturnStatement returnStatement)
{
StartNode(returnStatement);
WriteKeyword(ReturnStatement.ReturnKeywordRole);
if (!returnStatement.Expression.IsNull) {
Space();
returnStatement.Expression.AcceptVisitor(this);
}
Semicolon();
EndNode(returnStatement);
}
开发者ID:x-strong,项目名称:ILSpy,代码行数:11,代码来源:CSharpOutputVisitor.cs
示例8: Visit
public virtual void Visit(ReturnStatement expression)
{
if (expression.Expression != null)
{
outStream.Write("return ");
expression.Expression.Accept(this);
}
else
outStream.Write("return");
}
开发者ID:reshadi2,项目名称:mcjs,代码行数:10,代码来源:AstWriter.cs
示例9: VisitReturnStatement
public virtual void VisitReturnStatement (ReturnStatement returnStatement)
{
VisitChildren (returnStatement);
}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs
示例10: Exit
public virtual void Exit(ReturnStatement node)
{
}
开发者ID:buunguyen,项目名称:bike,代码行数:3,代码来源:EnterForWalkerGenerator.cs
示例11: Walk
// ReturnStatement
public virtual bool Walk(ReturnStatement node) { return true; }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:2,代码来源:PythonWalker.Generated.cs
示例12: VisitReturn
public void VisitReturn(ReturnStatement r)
{
if (r.Expression != null)
gen.Return(r.Expression.Accept(xlat));
else
gen.Return();
}
开发者ID:uxmal,项目名称:pytocs,代码行数:7,代码来源:StatementTranslator.cs
示例13: Enter
public virtual bool Enter(ReturnStatement node)
{
return true;
}
开发者ID:buunguyen,项目名称:bike,代码行数:4,代码来源:EnterForWalkerGenerator.cs
示例14: VisitReturnStatement
public override void VisitReturnStatement(ReturnStatement returnStatement)
{
if (!returnStatement.Expression.IsNull) {
AddIssue(
returnStatement,
string.Format (ctx.TranslateString("`{0}': A return keyword must not be followed by any expression when method returns void"), currentMethodName),
new CodeAction (
ctx.TranslateString("Remove returned expression"),
script => {
script.Remove(returnStatement.Expression);
}
)
);
}
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:15,代码来源:CS0127ReturnMustNotBeFollowedByAnyExpression.cs
示例15: GenerateReturnStatement
/// <summary>
/// Generates the code for a ReturnStatement node.
/// </summary>
/// <param name="rs">The ReturnStatement node.</param>
/// <returns>String containing C# code for ReturnStatement rs.</returns>
private string GenerateReturnStatement(ReturnStatement rs)
{
StringBuilder retVal = new StringBuilder();
bool dump = FuncCallsMarc();
if (IsParentEnumerable)
{
retVal.Append(GenerateLine("{ "));
if (rs.kids.Count == 0)
retVal.Append(GenerateLine("yield break;", rs));
else
{
retVal.Append(Generate(string.Format("yield return ({0})(", _currentGlobalFunctionDeclaration.ReturnType), rs));
foreach (SYMBOL kid in rs.kids)
retVal.Append(GenerateNode(kid));
retVal.Append(GenerateLine(");", null));
retVal.Append(GenerateLine("yield break;", null));
}
retVal.Append(GenerateLine("}"));
}
else
{
retVal.Append(Generate(string.Format("return ({0})", _currentGlobalFunctionDeclaration.ReturnType), rs));
foreach (SYMBOL kid in rs.kids)
retVal.Append(GenerateNode(kid));
}
if (dump)
return DumpFunc(dump) + retVal.ToString() + DumpAfterFunc(dump);
return retVal.ToString();
}
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:37,代码来源:CSCodeGenerator.cs
示例16: VisitReturnStatement
public virtual void VisitReturnStatement(ReturnStatement returnStatement)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(returnStatement);
}
}
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs
示例17: CSharpGrammar
//.........这里部分代码省略.........
createNode: node =>
{
var bodyNode = node.Children[4];
CheckForPossibleMistakenEmptyStatement(bodyNode);
return new UsingStatement()
{
UsingKeyword = (AstToken) node.Children[0].Result,
LeftParenthese = (AstToken) node.Children[1].Result,
DisposableObject = node.Children[2].Result,
RightParenthese = (AstToken) node.Children[3].Result,
Body = (Statement) bodyNode.Result
};
});
var breakStatement = new GrammarDefinition("BreakStatement",
rule: ToElement(BREAK)
+ ToElement(SEMICOLON),
createNode: node => new BreakStatement()
{
Keyword = (AstToken) node.Children[0].Result,
Semicolon = (AstToken) node.Children[1].Result
});
var continueStatement = new GrammarDefinition("ContinueStatement",
rule: ToElement(CONTINUE)
+ ToElement(SEMICOLON),
createNode: node => new BreakStatement()
{
Keyword = (AstToken) node.Children[0].Result,
Semicolon = (AstToken) node.Children[1].Result
});
var returnStatement = new GrammarDefinition("ReturnStatement",
rule: ToElement(RETURN)
+ expressionOptional
+ ToElement(SEMICOLON),
createNode: node =>
{
var result = new ReturnStatement();
result.ReturnKeyword = (AstToken) node.Children[0].Result;
if (node.Children[1].HasChildren)
result.Value = (Expression) node.Children[1].Result;
result.AddChild(AstNodeTitles.Semicolon, node.Children[2].Result);
return result;
});
var throwStatement = new GrammarDefinition("ThrowStatement",
rule: ToElement(THROW)
+ expressionOptional
+ ToElement(SEMICOLON),
createNode: node =>
{
var result = new ThrowStatement();
result.ThrowKeyword = (AstToken) node.Children[0].Result;
if (node.Children[1].HasChildren)
result.Expression = (Expression) node.Children[1].Result;
result.AddChild(AstNodeTitles.Semicolon, node.Children[2].Result);
return result;
});
var gotoStatement = new GrammarDefinition("GotoStatement",
rule: ToElement(GOTO)
+ identifierInsideBody
+ ToElement(SEMICOLON),
// TODO: goto case and goto default statements.
开发者ID:JerreS,项目名称:AbstractCode,代码行数:67,代码来源:CSharpGrammar.cs
示例18: VisitReturnStatement
public override StringBuilder VisitReturnStatement(ReturnStatement returnStatement, int data)
{
var result = new StringBuilder();
result.Append("return");
var exp = returnStatement.Expression.AcceptVisitor(this, data);
if (exp.Length > 0)
result.Append(" ").Append(exp);
result.Append(";");
return result;
}
开发者ID:mono-soc-2011,项目名称:SLSharp,代码行数:14,代码来源:GlslVisitor.cs
示例19: actionPerformed
/**
* Call back method that must be called as soon as the given <code>
* ReturnStatement</code> object has been traversed.
*
* @param pReturnStatement The <code>ReturnStatement</code> object that has
* just been traversed.
*/
public void actionPerformed(
ReturnStatement pReturnStatement)
{
// Nothing to do.
}
开发者ID:smartmobili,项目名称:parsing,代码行数:12,代码来源:TraverseActionAdapter.cs
示例20: PostWalk
public virtual void PostWalk(ReturnStatement node) { }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:1,代码来源:PythonWalker.Generated.cs
注:本文中的ReturnStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论