當前位置: 首頁>>代碼示例>>C#>>正文


C# CSharp.Catch類代碼示例

本文整理匯總了C#中Mono.CSharp.Catch的典型用法代碼示例。如果您正苦於以下問題:C# Catch類的具體用法?C# Catch怎麽用?C# Catch使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Catch類屬於Mono.CSharp命名空間,在下文中一共展示了Catch類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ConvertCatch

			CatchClause ConvertCatch(Catch ctch)
			{
				var result = new CatchClause();
				var location = LocationsBag.GetLocations(ctch);
				result.AddChild(new CSharpTokenNode(Convert(ctch.loc), CatchClause.CatchKeywordRole), CatchClause.CatchKeywordRole);
				if (ctch.TypeExpression != null) {
					if (location != null)
						result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
					
					if (ctch.TypeExpression != null)
						result.AddChild(ConvertToType(ctch.TypeExpression), Roles.Type);
					if (ctch.Variable != null && !string.IsNullOrEmpty(ctch.Variable.Name))
						result.AddChild(Identifier.Create(ctch.Variable.Name, Convert(ctch.Variable.Location)), Roles.Identifier);
					
					if (location != null && location.Count > 1)
						result.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
				}

				if (ctch.Block != null)
					result.AddChild((BlockStatement)ctch.Block.Accept(this), Roles.Body);
				
				return result;
			}
開發者ID:0xb1dd1e,項目名稱:NRefactory,代碼行數:23,代碼來源:CSharpParser.cs

示例2: ConvertCatch

			CatchClause ConvertCatch (Catch ctch) 
			{
				CatchClause result = new CatchClause ();
				var location = LocationsBag.GetLocations (ctch);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location[0]), "catch".Length), CatchClause.Roles.Keyword);
				
				if (ctch.Type_expr != null) {
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.LPar);
					
					result.AddChild ((INode)ctch.Type_expr.Accept (this), CatchClause.Roles.ReturnType);
					if (!string.IsNullOrEmpty (ctch.Name))
						result.AddChild (new Identifier (ctch.Name, Convert (location[1])), CatchClause.Roles.Identifier);
					
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), CatchClause.Roles.RPar);
				}
				
				result.AddChild ((INode)ctch.Block.Accept (this), CatchClause.Roles.Body);
				
				return result;
			}
開發者ID:pgoron,項目名稱:monodevelop,代碼行數:23,代碼來源:CSharpParser.cs

示例3: case_922

void case_922()
#line 6152 "cs-parser.jay"
{
	  	if (yyToken == Token.CLOSE_PARENS) {
			report.Error (1015, lexer.Location,
				"A type that derives from `System.Exception', `object', or `string' expected");
		} else {
			Error_SyntaxError (yyToken);
		}
		
		yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop]));
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:12,代碼來源:cs-parser.cs

示例4: case_923

void case_923()
#line 6163 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);

		/* Required otherwise missing block could not be detected because*/
		/* start_block is run early*/
		var c = new Catch (null, GetLocation (yyVals[-5+yyTop]));
		c.TypeExpression = (FullNamedExpression) yyVals[-3+yyTop];
		
		if (yyVals[-2+yyTop] != null) {
			var lt = (LocatedToken) yyVals[-2+yyTop];
			c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
		}

		if (yyVals[-2+yyTop] != null) {
			var lt = (LocatedToken) yyVals[-2+yyTop];
			c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
		}

		lbag.AddLocation (c, GetLocation (yyVals[-4+yyTop]), GetLocation (yyVals[-1+yyTop]));

		yyVal = c;
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:24,代碼來源:cs-parser.cs

示例5: yyparse


//.........這裏部分代碼省略.........
case 899:
  case_899();
  break;
case 900:
  case_900();
  break;
case 901:
  case_901();
  break;
case 902:
  case_902();
  break;
case 903:
  case_903();
  break;
case 904:
  case_904();
  break;
case 905:
  case_905();
  break;
case 906:
  case_906();
  break;
case 907:
  case_907();
  break;
case 908:
  case_908();
  break;
case 911:
#line 6082 "cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 912:
  case_912();
  break;
case 913:
  case_913();
  break;
case 914:
  case_914();
  break;
case 915:
  case_915();
  break;
case 916:
  case_916();
  break;
case 919:
#line 6131 "cs-parser.jay"
  {
		yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 920:
  case_920();
  break;
case 921:
#line 6150 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
開發者ID:segaman,項目名稱:NRefactory,代碼行數:67,代碼來源:cs-parser.cs

示例6: case_920

void case_920()
#line 6133 "cs-parser.jay"
{
		start_block (GetLocation (yyVals[-3+yyTop]));
		var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop]));
		c.TypeExpression = (FullNamedExpression) yyVals[-2+yyTop];

		if (yyVals[-1+yyTop] != null) {
			var lt = (LocatedToken) yyVals[-1+yyTop];
			c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
			current_block.AddLocalName (c.Variable);
		}

		lbag.AddLocation (c, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
		yyVal = c;
	  }
開發者ID:segaman,項目名稱:NRefactory,代碼行數:16,代碼來源:cs-parser.cs

示例7: yyparse


//.........這裏部分代碼省略.........
case 810:
  case_810();
  break;
case 817:
  case_817();
  break;
case 818:
  case_818();
  break;
case 819:
  case_819();
  break;
case 820:
  case_820();
  break;
case 821:
  case_821();
  break;
case 822:
  case_822();
  break;
case 823:
  case_823();
  break;
case 824:
  case_824();
  break;
case 825:
  case_825();
  break;
case 828:
#line 5266 "cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 829:
  case_829();
  break;
case 830:
  case_830();
  break;
case 831:
  case_831();
  break;
case 832:
  case_832();
  break;
case 833:
  case_833();
  break;
case 836:
#line 5319 "cs-parser.jay"
  {
		yyVal = new Catch ((Block) yyVals[0+yyTop], GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 837:
  case_837();
  break;
case 838:
#line 5338 "cs-parser.jay"
  {
		yyVal = yyVals[-1+yyTop];
	  }
  break;
開發者ID:Ein,項目名稱:monodevelop,代碼行數:67,代碼來源:cs-parser.cs

示例8: TryCatch

		public TryCatch (Block block, List<Catch> catch_clauses, Location l, bool inside_try_finally)
		{
			this.Block = block;
			this.Specific = catch_clauses;
			this.inside_try_finally = inside_try_finally;

			Catch c = catch_clauses [0];
			if (c.IsGeneral) {
				this.General = c;			
				catch_clauses.RemoveAt (0);
			}

			loc = l;
		}
開發者ID:alisci01,項目名稱:mono,代碼行數:14,代碼來源:statement.cs

示例9: case_935

void case_935()
#line 6221 "cs-parser.jay"
{
	  	var c = new Catch ((ExplicitBlock) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]));
	  	c.Filter = (CatchFilterExpression) yyVals[-1+yyTop];
	  	yyVal = c;
	  }
開發者ID:fanyjie,項目名稱:SharpDevelop,代碼行數:7,代碼來源:cs-parser.cs

示例10: yyparse


//.........這裏部分代碼省略.........
		}
		current_block.Toplevel.IsIterator = true;
		yyVal = new Yield ((Expression) yyVals[-1+yyTop], lt.Location); 
	  }
  break;
case 797:
#line 5125 "cs-parser.jay"
  {
		Report.Error (1627, GetLocation (yyVals[-1+yyTop]), "Expression expected after yield return");
		yyVal = null;
	  }
  break;
case 798:
#line 5130 "cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		string s = lt.Value;
		if (s != "yield"){
			Report.Error (1003, lt.Location, "; expected");
			yyVal = null;
		}
		if (RootContext.Version == LanguageVersion.ISO_1){
			Report.FeatureIsNotAvailable (lt.Location, "yield statement");
			yyVal = null;
		}
		
		current_block.Toplevel.IsIterator = true;
		yyVal = new YieldBreak (lt.Location);
	  }
  break;
case 801:
#line 5154 "cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 802:
#line 5158 "cs-parser.jay"
  {
		yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
	  }
  break;
case 803:
#line 5162 "cs-parser.jay"
  {
		yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List<Catch>) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]), true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
	  }
  break;
case 804:
#line 5166 "cs-parser.jay"
  {
		Report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally");
		yyVal = null;
	  }
  break;
case 805:
#line 5174 "cs-parser.jay"
  {
		var l = new List<Catch> (2);

		l.Add ((Catch) yyVals[0+yyTop]);
		yyVal = l;
	  }
  break;
case 806:
#line 5181 "cs-parser.jay"
開發者ID:speier,項目名稱:shake,代碼行數:67,代碼來源:cs-parser.cs

示例11: ConvertCatch

			CatchClause ConvertCatch (Catch ctch)
			{
				CatchClause result = new CatchClause ();
				var location = LocationsBag.GetLocations (ctch);
				result.AddChild (new CSharpTokenNode (Convert (ctch.loc), "catch".Length), CatchClause.Roles.Keyword);
				if (ctch.TypeExpression != null) {
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), CatchClause.Roles.LPar);
					
					result.AddChild (ConvertToType (ctch.TypeExpression), CatchClause.Roles.Type);
					if (ctch.Variable != null && !string.IsNullOrEmpty (ctch.Variable.Name))
						result.AddChild (new Identifier (ctch.Variable.Name, Convert (ctch.Variable.Location)), CatchClause.Roles.Identifier);
					
					if (location != null)
						result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), CatchClause.Roles.RPar);
				}
				
				result.AddChild ((BlockStatement)ctch.Block.Accept (this), CatchClause.Roles.Body);
				
				return result;
			}
開發者ID:madkat,項目名稱:NRefactory,代碼行數:21,代碼來源:CSharpParser.cs

示例12: TryCatch

		public TryCatch (Block block, ArrayList catch_clauses, Location l, bool inside_try_finally)
		{
			this.Block = block;
			this.Specific = catch_clauses;
			this.General = null;
			this.inside_try_finally = inside_try_finally;

			for (int i = 0; i < catch_clauses.Count; ++i) {
				Catch c = (Catch) catch_clauses [i];
				if (c.IsGeneral) {
					if (i != catch_clauses.Count - 1)
						Report.Error (1017, c.loc, "Try statement already has an empty catch block");
					this.General = c;
					catch_clauses.RemoveAt (i);
					i--;
				}
			}

			loc = l;
		}
開發者ID:lewurm,項目名稱:benchmarker,代碼行數:20,代碼來源:statement.cs

示例13: yyparse


//.........這裏部分代碼省略.........
		string s = lt.Value;
		if (s != "yield"){
			report.Error (1003, lt.Location, "; expected");
		} else if (yyVals[-1+yyTop] == null) {
			report.Error (1627, GetLocation (yyVals[0+yyTop]), "Expression expected after yield return");
		} else if (lang_version == LanguageVersion.ISO_1){
			FeatureIsNotAvailable (lt.Location, "iterators");
		}
		
		current_block.ParametersBlock.TopBlock.IsIterator = true;
		yyVal = new Yield ((Expression) yyVals[-1+yyTop], lt.Location);
		lbag.AddStatement (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 857:
#line 5718 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		var lt = (Tokenizer.LocatedToken) yyVals[-2+yyTop];
		string s = lt.Value;
		if (s != "yield"){
			report.Error (1003, lt.Location, "; expected");
		} else if (lang_version == LanguageVersion.ISO_1){
			FeatureIsNotAvailable (lt.Location, "iterators");
		}
		
		current_block.ParametersBlock.TopBlock.IsIterator = true;
		yyVal = new YieldBreak (lt.Location);
		lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
  break;
case 860:
#line 5740 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new TryCatch ((Block) yyVals[-1+yyTop], (List<Catch>) yyVals[0+yyTop], GetLocation (yyVals[-2+yyTop]), false);
	  }
  break;
case 861:
#line 5744 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new TryFinally ((Statement) yyVals[-2+yyTop], (Block) yyVals[0+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 862:
#line 5749 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		yyVal = new TryFinally (new TryCatch ((Block) yyVals[-3+yyTop], (List<Catch>) yyVals[-2+yyTop], GetLocation (yyVals[-4+yyTop]), true), (Block) yyVals[0+yyTop], GetLocation (yyVals[-4+yyTop]));
		lbag.AddStatement (yyVal, GetLocation (yyVals[-1+yyTop]));
	  }
  break;
case 863:
#line 5754 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		report.Error (1524, GetLocation (yyVals[-2+yyTop]), "Expected catch or finally");
		yyVal = null;
	  }
  break;
case 864:
#line 5762 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
  {
		var l = new List<Catch> (2);

		l.Add ((Catch) yyVals[0+yyTop]);
		yyVal = l;
	  }
  break;
開發者ID:runefs,項目名稱:Marvin,代碼行數:67,代碼來源:cs-parser.cs

示例14: case_841

void case_841()
#line 5334 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
	  	if (yyToken == Token.CLOSE_PARENS) {
			Report.Error (1015, lexer.Location,
				"A type that derives from `System.Exception', `object', or `string' expected");
		} else {
			Error_SyntaxError (yyToken);
		}
		
		yyVal = new Catch (null, GetLocation (yyVals[-2+yyTop]));
	  }
開發者ID:RainsSoft,項目名稱:MonoCompilerAsAService,代碼行數:12,代碼來源:cs-parser.cs

示例15: case_839

void case_839()
#line 5315 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
		start_block (GetLocation (yyVals[-3+yyTop]));
		var c = new Catch (current_block, GetLocation (yyVals[-4+yyTop]));
		c.TypeExpression = (FullNamedExpression) yyVals[-2+yyTop];

		if (yyVals[-1+yyTop] != null) {
			var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
			c.Variable = new LocalVariable (current_block, lt.Value, lt.Location);
			current_block.AddLocalName (c.Variable);
		}
		
		lbag.AddLocation (c, GetLocation (yyVals[-3+yyTop]), GetLocation (yyVals[0+yyTop]));
		yyVal = c;
	  }
開發者ID:RainsSoft,項目名稱:MonoCompilerAsAService,代碼行數:16,代碼來源:cs-parser.cs


注:本文中的Mono.CSharp.Catch類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。