当前位置: 首页>>代码示例>>C#>>正文


C# CodeDom.CodeCatchClause类代码示例

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


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

示例1: Constructor0

		public void Constructor0 ()
		{
			CodeCatchClause ccc = new CodeCatchClause ();

			Assert.IsNotNull (ccc.CatchExceptionType, "#1");
			Assert.AreEqual (typeof(Exception).FullName, ccc.CatchExceptionType.BaseType, "#2");

			Assert.IsNotNull (ccc.LocalName, "#3");
			Assert.AreEqual (string.Empty, ccc.LocalName, "#4");

			Assert.IsNotNull (ccc.Statements, "#5");
			Assert.AreEqual (0, ccc.Statements.Count, "#6");

			ccc.LocalName = null;
			Assert.IsNotNull (ccc.LocalName, "#7");
			Assert.AreEqual (string.Empty, ccc.LocalName, "#8");

			string localName = "mono";
			ccc.LocalName = localName;
			Assert.AreSame (localName, ccc.LocalName, "#9");

			ccc.CatchExceptionType = null;
			Assert.IsNotNull (ccc.CatchExceptionType, "#10");
			Assert.AreEqual (typeof(Exception).FullName, ccc.CatchExceptionType.BaseType, "#11");

			CodeTypeReference cet = new CodeTypeReference("SomeException");
			ccc.CatchExceptionType = cet;
			Assert.AreSame (cet, ccc.CatchExceptionType, "#12");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:29,代码来源:CodeCatchClauseTest.cs

示例2: Emit

        // Generate a codedom exception handler statement
        public static CodeStatement Emit(ExceptionHandler ex)
        {
            // Create the codedom exception handler statement
            var codeTry = new CodeTryCatchFinallyStatement();

            // Add the statements in the try block
            foreach (var e in ex.Try.ChildExpressions)
                codeTry.TryStatements.Add(CodeDomEmitter.EmitCodeStatement(e));

            // Add all the catch clauses.
            foreach (var c in ex.CatchClauses)
            {
                // Create the codedom catch statement.
                var catchClause = new CodeCatchClause();
                // To do: replace with non-test code
                catchClause.CatchExceptionType = new CodeTypeReference("System.Exception");
                catchClause.LocalName = "ex";
                codeTry.CatchClauses.Add(catchClause);

                // Add the statemnts in the catch block
                foreach(var e in c.ChildExpressions)
                    catchClause.Statements.Add(CodeDomEmitter.EmitCodeStatement(e));
            }

            // Add the statements in the finally block.
            foreach (var e in ex.Finally.ChildExpressions)
                codeTry.FinallyStatements.Add(CodeDomEmitter.EmitCodeStatement(e));

            return codeTry;
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:31,代码来源:ExceptionHandlerEmitter.cs

示例3: AddRange

 /// <devdoc>
 /// <para>Copies the elements of an array to the end of the <see cref='System.CodeDom.CodeCatchClauseCollection'/>.</para>
 /// </devdoc>
 public void AddRange(CodeCatchClause[] value) {
     if (value == null) {
         throw new ArgumentNullException("value");
     }
     for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) {
         this.Add(value[i]);
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:11,代码来源:CodeCatchClauseCollection.cs

示例4: CodeTryCatchFinallyStatement

		public CodeTryCatchFinallyStatement (CodeStatement [] tryStatements,
						     CodeCatchClause [] catchClauses,
						     CodeStatement [] finallyStatements)
		{
			TryStatements.AddRange( tryStatements );
			CatchClauses.AddRange( catchClauses );
			FinallyStatements.AddRange( finallyStatements );
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:8,代码来源:CodeTryCatchFinallyStatement.cs

示例5: CodeTryCatchFinallyStatement

 public CodeTryCatchFinallyStatement(CodeStatement[] tryStatements, CodeCatchClause[] catchClauses)
 {
     this.tryStatments = new CodeStatementCollection();
     this.finallyStatments = new CodeStatementCollection();
     this.catchClauses = new CodeCatchClauseCollection();
     this.TryStatements.AddRange(tryStatements);
     this.CatchClauses.AddRange(catchClauses);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:CodeTryCatchFinallyStatement.cs

示例6: Constructor1_NullItem

		public void Constructor1_NullItem ()
		{
			CodeCatchClause[] catchClauses = new CodeCatchClause[] { 
				new CodeCatchClause (), null };

			CodeCatchClauseCollection coll = new CodeCatchClauseCollection (
				catchClauses);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeCatchClauseCollectionTest.cs

示例7: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeCatchClause ccc = new CodeCatchClause ("mono");
			Assert.AreEqual ("System.Exception", ccc.CatchExceptionType.BaseType, "CatchExceptionType.BaseType");
			ccc.CatchExceptionType = new CodeTypeReference ("System.Void");
			Assert.AreEqual ("mono", ccc.LocalName, "LocalName");
			ccc.LocalName = String.Empty;
			Assert.AreEqual (0, ccc.Statements.Count, "Statements");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeCatchClauseCas.cs

示例8: Clone

 public static CodeCatchClause Clone(this CodeCatchClause clause)
 {
     if (clause == null) return null;
     CodeCatchClause c = new CodeCatchClause();
     c.CatchExceptionType = clause.CatchExceptionType.Clone();
     c.LocalName = clause.LocalName;
     c.Statements.AddRange(clause.Statements.Clone());
     return c;
 }
开发者ID:jw56578,项目名称:SpecFlowTest,代码行数:9,代码来源:CodeCatchClauseExtensions.cs

示例9: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeStatement[] try_statements = new CodeStatement[1] { new CodeStatement () };
			CodeCatchClause[] catch_clauses = new CodeCatchClause[1] { new CodeCatchClause () };
			CodeTryCatchFinallyStatement ctcfs = new CodeTryCatchFinallyStatement (try_statements, catch_clauses);
			Assert.AreEqual (1, ctcfs.CatchClauses.Count, "CatchClauses");
			Assert.AreEqual (0, ctcfs.FinallyStatements.Count, "FinallyStatements");
			Assert.AreEqual (1, ctcfs.TryStatements.Count, "TryStatements");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:CodeTryCatchFinallyStatementCas.cs

示例10: Catch

 private static CodeCatchClause Catch(System.Type type, string name, CodeStatement catchStmnt)
 {
     CodeCatchClause clause = new CodeCatchClause {
         CatchExceptionType = Type(type),
         LocalName = name
     };
     clause.Statements.Add(catchStmnt);
     return clause;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:TypedDataSetGenerator.cs

示例11: AddRange

		public void AddRange (CodeCatchClause [] value)
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}

			for (int i = 0; i < value.Length; i++) {
				Add (value[i]);
			}
		}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:10,代码来源:CodeCatchClauseCollection.cs

示例12: PushCatch

 public CodeDomStatments PushCatch(string localName)
 {
     Pop();
     var SS = _Data.Peek();
     var S = SS[SS.Count - 1] as CodeTryCatchFinallyStatement;
     var c = new CodeCatchClause(localName);
     S.CatchClauses.Add(c);
     _Data.Push(c.Statements);
     return this;
 }
开发者ID:DzmitrySo,项目名称:mc,代码行数:10,代码来源:CodeDomStatments.cs

示例13: Catch

 internal static CodeCatchClause Catch(CodeTypeReference type, string name, CodeStatement catchStmnt)
 {
     CodeCatchClause clause = new CodeCatchClause {
         CatchExceptionType = type,
         LocalName = name
     };
     if (catchStmnt != null)
     {
         clause.Statements.Add(catchStmnt);
     }
     return clause;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:12,代码来源:CodeGenHelper.cs

示例14: Constructor1

		public void Constructor1 ()
		{
			CodeCatchClause cc1 = new CodeCatchClause ();
			CodeCatchClause cc2 = new CodeCatchClause ();

			CodeCatchClause[] catchClauses = new CodeCatchClause[] { cc1, cc2 };
			CodeCatchClauseCollection coll = new CodeCatchClauseCollection (
				catchClauses);

			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (cc1), "#2");
			Assert.AreEqual (1, coll.IndexOf (cc2), "#3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CodeCatchClauseCollectionTest.cs

示例15: Constructor2

		public void Constructor2 ()
		{
			CodeCatchClause cc1 = new CodeCatchClause ();
			CodeCatchClause cc2 = new CodeCatchClause ();

			CodeCatchClauseCollection c = new CodeCatchClauseCollection ();
			c.Add (cc1);
			c.Add (cc2);

			CodeCatchClauseCollection coll = new CodeCatchClauseCollection (c);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (cc1), "#2");
			Assert.AreEqual (1, coll.IndexOf (cc2), "#3");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:CodeCatchClauseCollectionTest.cs


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