• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TryCatchStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TryCatchStatement的典型用法代码示例。如果您正苦于以下问题:C# TryCatchStatement类的具体用法?C# TryCatchStatement怎么用?C# TryCatchStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TryCatchStatement类属于命名空间,在下文中一共展示了TryCatchStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: VisitTryCatchStatement

 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if(tryCatchStatement.CatchClauses.Count > 0 && !tryCatchStatement.FinallyBlock.IsNull)
     {
         UnlockWith(tryCatchStatement);
     }
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
开发者ID:vlad2135,项目名称:strokes,代码行数:8,代码来源:TryCatchFinallyStatementAchievement.cs


示例2: VisitTryCatchStatement

 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.CatchClauses.Count > 5)
     {
         UnlockWith(tryCatchStatement);
     }
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:8,代码来源:CatchManyExceptions.cs


示例3: VisitTryCatchStatement

            public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
            {
                var defaultCatchClause = tryCatchStatement.CatchClauses.FirstOrDefault(a => a.Type.IsNull);
                if(defaultCatchClause != null)
                {
                    UnlockWith(defaultCatchClause);
                }

                return base.VisitTryCatchStatement(tryCatchStatement, data);
            }
开发者ID:vlad2135,项目名称:strokes,代码行数:10,代码来源:TryCatchIgnoreStatementAchievement.cs


示例4: TestEmptyFinallyDoesNotMatchNullFinally

		public void TestEmptyFinallyDoesNotMatchNullFinally()
		{
			TryCatchStatement c1 = new TryCatchStatement {
				TryBlock = new BlockStatement(),
				CatchClauses = { new CatchClause { Body = new BlockStatement() } }
			};
			TryCatchStatement c2 = new TryCatchStatement {
				TryBlock = new BlockStatement(),
				CatchClauses = { new CatchClause { Body = new BlockStatement() } },
				FinallyBlock = new BlockStatement()
			};
			Assert.IsFalse(c1.IsMatch(c2));
			Assert.IsFalse(c2.IsMatch(c1)); // and vice versa
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:14,代码来源:TryCatchStatementTests.cs


示例5: VisitTryCatchStatement

 public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
 {
     if (tryCatchStatement.CatchClauses.Count > 0)
     {
         foreach (CatchClause catchClause in tryCatchStatement.CatchClauses)
         {
             var throwStatement = catchClause.Body.Statements.FirstOrDefault(a => a is ThrowStatement);
             if(throwStatement != null)
             {
                 UnlockWith(throwStatement);
             }
         }
     }
     return base.VisitTryCatchStatement(tryCatchStatement, data);
 }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:15,代码来源:TryCatchRethrowStatementAchievement.cs


示例6: VisitTryCatchStatement

			public override void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
			{
				var redundantCatchClauses = new List<CatchClause>();
				bool hasNonRedundantCatch = false;
				foreach (var catchClause in tryCatchStatement.CatchClauses) {
					if (IsRedundant(catchClause)) {
						redundantCatchClauses.Add(catchClause);
					} else {
						hasNonRedundantCatch = true;
					}
				}

				if (hasNonRedundantCatch || !tryCatchStatement.FinallyBlock.IsNull) {
					AddIssuesForClauses(redundantCatchClauses);
				} else {
					AddIssueForTryCatchStatement(tryCatchStatement);
				}
			}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:18,代码来源:RedundantCatchIssue.cs


示例7: VisitTryCatchStatement

 public virtual void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
 {
     if (this.ThrowException)
     {
         throw (Exception)this.CreateException(tryCatchStatement);
     }
 }
开发者ID:fabriciomurta,项目名称:BridgeUnified,代码行数:7,代码来源:Visitor.Exception.cs


示例8: VisitTryCatchStatement

		public virtual void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
		{
			StartNode(tryCatchStatement);
			WriteKeyword(TryCatchStatement.TryKeywordRole);
			WriteBlock(tryCatchStatement.TryBlock, policy.StatementBraceStyle);
			foreach (var catchClause in tryCatchStatement.CatchClauses) {
				if (policy.CatchNewLinePlacement == NewLinePlacement.SameLine)
					Space();
				else
					NewLine();
				catchClause.AcceptVisitor(this);
			}
			if (!tryCatchStatement.FinallyBlock.IsNull) {
				if (policy.FinallyNewLinePlacement == NewLinePlacement.SameLine)
					Space();
				else
					NewLine();
				WriteKeyword(TryCatchStatement.FinallyKeywordRole);
				WriteBlock(tryCatchStatement.FinallyBlock, policy.StatementBraceStyle);
			}
			NewLine();
			EndNode(tryCatchStatement);
		}
开发者ID:icsharpcode,项目名称:NRefactory,代码行数:23,代码来源:CSharpOutputVisitor.cs


示例9: VisitTryCatchStatement

		public override void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
		{
			if (!tryCatchStatement.TryBlock.IsNull) {
				FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.TryBlock);
			}
			
			foreach (CatchClause clause in tryCatchStatement.CatchClauses) {
				PlaceOnNewLine(policy.PlaceCatchOnNewLine, clause.CatchToken);
				if (!clause.LParToken.IsNull) {
					ForceSpacesBefore(clause.LParToken, policy.SpaceBeforeCatchParentheses);

					ForceSpacesAfter(clause.LParToken, policy.SpacesWithinCatchParentheses);
					ForceSpacesBefore(clause.RParToken, policy.SpacesWithinCatchParentheses);
				}
				FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, clause.Body);
			}
			
			if (!tryCatchStatement.FinallyBlock.IsNull) {
				PlaceOnNewLine(policy.PlaceFinallyOnNewLine, tryCatchStatement.FinallyToken);
				
				FixEmbeddedStatment(policy.StatementBraceStyle, BraceForcement.DoNotChange, tryCatchStatement.FinallyBlock);
			}
			
		}
开发者ID:txdv,项目名称:monodevelop,代码行数:24,代码来源:AstFormattingVisitor.cs


示例10: VisitTryCatchStatement

 public virtual void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
 {
     VisitBlock(tryCatchStatement.TryBlock);
     VisitBlock(tryCatchStatement.CatchBlock);
 }
开发者ID:xuld,项目名称:DocPlus,代码行数:5,代码来源:DocAstVistor.cs


示例11: VisitTryCatchStatement

		public override object VisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data)
		{
			if (tryCatchStatement == null) {
				return data;
			}
			if (tryCatchStatement.StatementBlock != null) {
				tryCatchStatement.StatementBlock.AcceptVisitor(this, data);
			}
			if (tryCatchStatement.CatchClauses != null) {
				foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) {
					if (catchClause != null) {
						if (catchClause.TypeReference != null && catchClause.VariableName != null) {
							AddVariable(catchClause.TypeReference,
							            catchClause.VariableName,
							            catchClause.StatementBlock.StartLocation,
							            catchClause.StatementBlock.EndLocation,
							            false, false, null, null);
						}
						catchClause.StatementBlock.AcceptVisitor(this, data);
					}
				}
			}
			if (tryCatchStatement.FinallyBlock != null) {
				return tryCatchStatement.FinallyBlock.AcceptVisitor(this, data);
			}
			return data;
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:27,代码来源:LookupTableVisitor.cs


示例12: VisitTryCatchStatement

		public virtual void VisitTryCatchStatement(TryCatchStatement tryCatchStatement)
		{
			StartNode(tryCatchStatement);
			var oldRef = currentTryReference;
			currentTryReference = new object();
			WriteKeywordReference(TryCatchStatement.TryKeywordRole, currentTryReference);
			tryCatchStatement.TryBlock.AcceptVisitor(this);
			int count = 0;
			foreach (var catchClause in tryCatchStatement.CatchClauses) {
				if (count-- <= 0) {
					cancellationToken.ThrowIfCancellationRequested();
					count = CANCEL_CHECK_LOOP_COUNT;
				}
				catchClause.AcceptVisitor(this);
			}
			if (!tryCatchStatement.FinallyBlock.IsNull) {
				WriteKeywordReference(TryCatchStatement.FinallyKeywordRole, currentTryReference);
				tryCatchStatement.FinallyBlock.AcceptVisitor(this);
			}
			currentTryReference = oldRef;
			EndNode(tryCatchStatement);
		}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:22,代码来源:CSharpOutputVisitor.cs


示例13: TryStatement

	void TryStatement(
#line  3245 "VBNET.ATG" 
out Statement tryStatement) {

#line  3247 "VBNET.ATG" 
		Statement blockStmt = null, finallyStmt = null;List<CatchClause> catchClauses = null;
		
		Expect(203);
		EndOfStmt();
		Block(
#line  3250 "VBNET.ATG" 
out blockStmt);
		if (la.kind == 62 || la.kind == 100 || la.kind == 110) {
			CatchClauses(
#line  3251 "VBNET.ATG" 
out catchClauses);
		}
		if (la.kind == 110) {
			lexer.NextToken();
			EndOfStmt();
			Block(
#line  3252 "VBNET.ATG" 
out finallyStmt);
		}
		Expect(100);
		Expect(203);

#line  3255 "VBNET.ATG" 
		tryStatement = new TryCatchStatement(blockStmt, catchClauses, finallyStmt);
		
	}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:31,代码来源:Parser.cs


示例14: VisitTryCatchStatement

		public virtual void VisitTryCatchStatement (TryCatchStatement tryCatchStatement)
		{
			VisitChildren (tryCatchStatement);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:DepthFirstAstVisitor.cs


示例15: Visit

			public override object Visit (TryCatch tryCatchStatement)
			{
				var result = new TryCatchStatement ();
				result.AddChild (new CSharpTokenNode (Convert (tryCatchStatement.loc), "try".Length), TryCatchStatement.TryKeywordRole);
				result.AddChild ((INode)tryCatchStatement.Block.Accept (this), TryCatchStatement.TryBlockRole);
				foreach (Catch ctch in tryCatchStatement.Specific) {
					result.AddChild (ConvertCatch (ctch), TryCatchStatement.CatchClauseRole);
				}
				if (tryCatchStatement.General != null)
					result.AddChild (ConvertCatch (tryCatchStatement.General), TryCatchStatement.CatchClauseRole);
				
				return result;
			}
开发者ID:pgoron,项目名称:monodevelop,代码行数:13,代码来源:CSharpParser.cs


示例16: TryCatchBlock

 public TryCatchBlock(IEmitter emitter, TryCatchStatement tryCatchStatement)
     : base(emitter, tryCatchStatement)
 {
     this.Emitter = emitter;
     this.TryCatchStatement = tryCatchStatement;
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:6,代码来源:TryCatchBlock.cs


示例17: CSharpGrammar


//.........这里部分代码省略.........
                    + blockStatement,
                createNode: node =>
                {
                    var result = new CatchClause();
                    result.CatchKeyword = (AstToken) node.Children[0].Result;
                    result.LeftParenthese = (AstToken) node.Children[1].Result;
                    result.ExceptionType = (TypeReference) node.Children[2].Result;

                    if (node.Children[3].HasChildren)
                        result.ExceptionIdentifier = (Identifier) node.Children[3].Result;

                    result.RightParenthese = (AstToken) node.Children[4].Result;
                    result.Body = (BlockStatement) node.Children[5].Result;
                    return result;
                });

            var generalCatchClause = new GrammarDefinition("GeneralCatchClause",
                rule: ToElement(CATCH) + blockStatement,
                createNode: node => new CatchClause
                {
                    CatchKeyword = (AstToken) node.Children[0].Result,
                    Body = (BlockStatement) node.Children[1].Result
                });

            var catchClause = new GrammarDefinition("CatchClause",
                rule: specificCatchClause | generalCatchClause);

            var catchClauses = new GrammarDefinition("CatchClauses");
            catchClauses.Rule = catchClause | catchClauses + catchClause;

            var finallyClause = new GrammarDefinition("FinallyClause",
                rule: ToElement(FINALLY) + blockStatement);

            var tryCatchStatement = new GrammarDefinition("TryCatchStatement",
                rule: ToElement(TRY) + blockStatement + catchClauses
                      | ToElement(TRY) + blockStatement + finallyClause
                      | ToElement(TRY) + blockStatement + catchClauses + finallyClause,
                createNode: node =>
                {
                    var result = new TryCatchStatement();
                    result.TryKeyword = (AstToken) node.Children[0].Result;
                    result.TryBlock = (BlockStatement) node.Children[1].Result;

                    ParserNode finallyClauseNode = null;
                    if (node.Children[2].GrammarElement == finallyClause)
                    {
                        finallyClauseNode = node.Children[2];
                    }
                    else
                    {
                        result.CatchClauses.AddRange(node.Children[2].GetAllListAstNodes<CatchClause>());
                    }

                    if (node.Children.Count == 4)
                        finallyClauseNode = node.Children[3];

                    if (finallyClauseNode != null)
                    {
                        result.FinallyKeyword = (AstToken) finallyClauseNode.Children[0].Result;
                        result.FinallyBlock = (BlockStatement) finallyClauseNode.Children[1].Result;
                    }

                    return result;
                });

            var unsafeStatement = new GrammarDefinition("UnsafeStatement",
开发者ID:JerreS,项目名称:AbstractCode,代码行数:67,代码来源:CSharpGrammar.cs


示例18: Visit

 public override void Visit(TryCatchStatement node) { this.action(node); }
开发者ID:yaakoviyun,项目名称:sqlskim,代码行数:1,代码来源:AllNodesVisitor.cs


示例19: VisitTryCatchStatement

 public StringBuilder VisitTryCatchStatement(TryCatchStatement tryCatchStatement, int data)
 {
     throw new SLSharpException("SL# does not have exceptions.");
 }
开发者ID:hach-que,项目名称:SLSharp,代码行数:4,代码来源:VisitorBase.Illegal.cs


示例20: ExplicitVisit

 public override void ExplicitVisit(TryCatchStatement fragment)
 {
     _fragments.Add(fragment);
 }
开发者ID:trevor-hingley,项目名称:controcc_sql_utilities,代码行数:4,代码来源:oVisitorAll.cs



注:本文中的TryCatchStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TryFuncUntilTimeOut类代码示例发布时间:2022-05-24
下一篇:
C# TrivialHashtable类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap