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


C# CodeDom.CodeTryCatchFinallyStatement类代码示例

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


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

示例1: Constructor0_Deny_Unrestricted

		public void Constructor0_Deny_Unrestricted ()
		{
			CodeTryCatchFinallyStatement ctcfs = new CodeTryCatchFinallyStatement ();
			Assert.AreEqual (0, ctcfs.CatchClauses.Count, "CatchClauses");
			Assert.AreEqual (0, ctcfs.FinallyStatements.Count, "FinallyStatements");
			Assert.AreEqual (0, ctcfs.TryStatements.Count, "TryStatements");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:CodeTryCatchFinallyStatementCas.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: 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

示例4: TypescriptTryCatchFinallyStatement

 public TypescriptTryCatchFinallyStatement(
     IStatementFactory statementFactory,
     IExpressionFactory expressionFactory,
     CodeTryCatchFinallyStatement statement,
     CodeGeneratorOptions options)
 {
     _statementFactory = statementFactory;
     _expressionFactory = expressionFactory;
     _statement = statement;
     _options = options;
     _typescriptTypeMapper = new TypescriptTypeMapper();
 }
开发者ID:s2quake,项目名称:TypescriptCodeDom,代码行数:12,代码来源:TypescriptTryCatchFinallyStatement.cs

示例5: Clone

 public static CodeTryCatchFinallyStatement Clone(this CodeTryCatchFinallyStatement statement)
 {
     if (statement == null) return null;
     CodeTryCatchFinallyStatement s = new CodeTryCatchFinallyStatement();
     s.CatchClauses.AddRange(statement.CatchClauses.Clone());
     s.EndDirectives.AddRange(statement.EndDirectives);
     s.FinallyStatements.AddRange(statement.FinallyStatements.Clone());
     s.LinePragma = statement.LinePragma;
     s.StartDirectives.AddRange(statement.StartDirectives);
     s.TryStatements.AddRange(statement.TryStatements.Clone());
     s.UserData.AddRange(statement.UserData);
     return s;
 }
开发者ID:mgagne-atman,项目名称:Projects,代码行数:13,代码来源:CodeTryCatchFinallyStatementExtensions.cs

示例6: CreateMember

        /// <summary>
        /// 
        /// </summary>
        /// <param name="member"></param>
        /// <param name="inner"></param>
        /// <param name="attrs"></param>
        /// <returns></returns>
        public CodeTypeMember CreateMember(MemberInfo member, CodeFieldReferenceExpression inner, MemberAttributes attrs)
        {
            Debug.Assert(member is MethodInfo);
            MethodInfo method = member as MethodInfo;
            CodeMemberMethod codeMethod = new CodeMemberMethod();

            codeMethod.Name = method.Name;
            codeMethod.ReturnType = new CodeTypeReference(method.ReturnType);
            codeMethod.Attributes = attrs;

            // try
            CodeTryCatchFinallyStatement tryCode = new CodeTryCatchFinallyStatement();

            // decleare parameters
            List<CodeArgumentReferenceExpression> codeParamiteRefrs = new List<CodeArgumentReferenceExpression>();

            foreach (ParameterInfo codeParameter in method.GetParameters()) {
                CodeParameterDeclarationExpression codeParameterDeclare = new CodeParameterDeclarationExpression(codeParameter.ParameterType, codeParameter.Name);
                codeMethod.Parameters.Add(codeParameterDeclare);
                codeParamiteRefrs.Add(new CodeArgumentReferenceExpression(codeParameter.Name));
            }

            // invoke
            CodeMethodInvokeExpression invokeMethod = new CodeMethodInvokeExpression(
                inner, method.Name, codeParamiteRefrs.ToArray());
            if (method.ReturnType.Name.ToLower() == "void") {
                tryCode.TryStatements.Add(invokeMethod);
            } else {
                CodeVariableDeclarationStatement var = new CodeVariableDeclarationStatement(method.ReturnType, "returnObject", invokeMethod);
                //CodeAssignStatement assign = new CodeAssignStatement(var, invokeMethod);
                tryCode.TryStatements.Add(var);

                CodeCommentStatement todo = new CodeCommentStatement("TODO: your code", false);
                tryCode.TryStatements.Add(todo);

                CodeVariableReferenceExpression varRef = new CodeVariableReferenceExpression("returnObject");
                CodeMethodReturnStatement codeReturn = new CodeMethodReturnStatement(varRef);
                tryCode.TryStatements.Add(codeReturn);
            }

            // catch
            CodeTypeReference codeTypeRef = new CodeTypeReference(typeof(Exception));
            CodeCatchClause catchClause = new CodeCatchClause("ex", codeTypeRef);
            catchClause.Statements.Add(new CodeThrowExceptionStatement());
            tryCode.CatchClauses.Add(catchClause);

            codeMethod.Statements.Add(tryCode);
            return codeMethod;
        }
开发者ID:yangwen27,项目名称:moonlit,代码行数:56,代码来源:MemberMethodInfoFactory.cs

示例7: VisitUsingStatement

        public override object VisitUsingStatement(UsingStatement usingStatement, object data)
        {
            // using (new expr) { stmts; }
            //
            // emulate with
            //      object _dispose;
            //      try
            //      {
            //          _dispose = new expr;
            //
            //          stmts;
            //      }
            //      finally
            //      {
            //          if (((_dispose != null)
            //              && (typeof(System.IDisposable).IsInstanceOfType(_dispose) == true)))
            //          {
            //              ((System.IDisposable)(_dispose)).Dispose();
            //          }
            //      }
            //

            usingId++; // in case nested using() statements
            string name = "_dispose" + usingId.ToString();

            CodeVariableDeclarationStatement disposable = new CodeVariableDeclarationStatement("System.Object", name, new CodePrimitiveExpression(null));

            AddStmt(disposable);

            CodeTryCatchFinallyStatement tryStmt = new CodeTryCatchFinallyStatement();

            CodeVariableReferenceExpression left1 = new CodeVariableReferenceExpression(name);

            codeStack.Push(NullStmtCollection); // send statements to nul Statement collection
            CodeExpression right1 = (CodeExpression)usingStatement.ResourceAcquisition.AcceptVisitor(this, data);
            codeStack.Pop();

            CodeAssignStatement assign1 = new CodeAssignStatement(left1, right1);

            tryStmt.TryStatements.Add(assign1);
            tryStmt.TryStatements.Add(new CodeSnippetStatement());

            codeStack.Push(tryStmt.TryStatements);
            usingStatement.EmbeddedStatement.AcceptChildren(this, data);
            codeStack.Pop();

            CodeMethodInvokeExpression isInstanceOfType = new CodeMethodInvokeExpression(new CodeTypeOfExpression(typeof(IDisposable)), "IsInstanceOfType", new CodeExpression[] { left1 });

            CodeConditionStatement if1 = new CodeConditionStatement();
            if1.Condition = new CodeBinaryOperatorExpression(new CodeBinaryOperatorExpression(left1, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)),
                                                             CodeBinaryOperatorType.BooleanAnd,
                                                             new CodeBinaryOperatorExpression(isInstanceOfType, CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(true)));
            if1.TrueStatements.Add(new CodeMethodInvokeExpression(new CodeCastExpression(typeof(IDisposable),left1), "Dispose", new CodeExpression[] { }));

            tryStmt.FinallyStatements.Add(if1);

            // Add Statement to Current Statement Collection
            AddStmt(tryStmt);

            return null;
        }
开发者ID:richardschneider,项目名称:ILSpy,代码行数:61,代码来源:CodeDOMOutputVisitor.cs

示例8: GenerateTryCatchFinallyStatement

		protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement e)
		{
		}
开发者ID:Profit0004,项目名称:mono,代码行数:3,代码来源:CodeGeneratorCas.cs

示例9: GenerateTryCatchFinallyStatement

		protected override void GenerateTryCatchFinallyStatement (CodeTryCatchFinallyStatement statement)
		{
			TextWriter output = Output;

			output.WriteLine ("Try ");
			++Indent;
			GenerateStatements (statement.TryStatements);
			--Indent;
			
			foreach (CodeCatchClause clause in statement.CatchClauses) {
				output.Write ("Catch ");
				OutputTypeNamePair (clause.CatchExceptionType, clause.LocalName);
				output.WriteLine ();
				++Indent;
				GenerateStatements (clause.Statements);
				--Indent;
			}

			CodeStatementCollection finallies = statement.FinallyStatements;
			if (finallies.Count > 0) {
				output.WriteLine ("Finally");
				++Indent;
				GenerateStatements (finallies);
				--Indent;
			}

			output.WriteLine("End Try");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:28,代码来源:VBCodeGenerator.cs

示例10: Visit

			public void Visit (CodeTryCatchFinallyStatement o)
			{
				g.GenerateTryCatchFinallyStatement (o);
			}
开发者ID:carrie901,项目名称:mono,代码行数:4,代码来源:CodeGenerator.cs

示例11: BuildCodeDomTree

		public override void BuildCodeDomTree (CodeCompileUnit compileUnit)
		{
         
			CodeThisReferenceExpression @this = new CodeThisReferenceExpression ();
			CodeBaseReferenceExpression @base = new CodeBaseReferenceExpression ();
			CodeTypeReferenceExpression thisType = new CodeTypeReferenceExpression (new CodeTypeReference (GeneratedTypeName));
			CodeTypeReference uriType = new CodeTypeReference (typeof(Uri));

			CodeMemberField executableField = new CodeMemberField {
            Name = "_Executable",
            Type = new CodeTypeReference(typeof(XsltExecutable)),
            Attributes = MemberAttributes.Private | MemberAttributes.Static
         };

			// methods

			// cctor
			CodeTypeConstructor cctor = new CodeTypeConstructor {
            CustomAttributes = { 
               new CodeAttributeDeclaration(DebuggerNonUserCodeTypeReference)
            }
         };

			CodeVariableDeclarationStatement procVar = new CodeVariableDeclarationStatement {
            Name = "proc",
            Type = new CodeTypeReference(typeof(IXsltProcessor)),
            InitExpression = new CodeIndexerExpression {
               TargetObject = new CodePropertyReferenceExpression {
                  PropertyName = "Xslt",
                  TargetObject = new CodeTypeReferenceExpression(typeof(Processors))
               },
               Indices = { 
                  new CodePrimitiveExpression(parser.ProcessorName)
               }
            } 
         };

			CodeVariableDeclarationStatement sourceVar = new CodeVariableDeclarationStatement {
            Name = "source",
            Type = new CodeTypeReference(typeof(Stream)),
            InitExpression = new CodePrimitiveExpression(null)
         };

			CodeVariableDeclarationStatement sourceUriVar = new CodeVariableDeclarationStatement {
            Name = "sourceUri",
            Type = uriType,
            InitExpression = new CodeObjectCreateExpression {
               CreateType = uriType,
               Parameters = {
                  new CodePrimitiveExpression(ValidatorUri.AbsoluteUri)
               }
            }
         };

			CodeVariableDeclarationStatement resolverVar = new CodeVariableDeclarationStatement {
            Name = "resolver",
            Type = new CodeTypeReference(typeof(XmlResolver)),
            InitExpression = new CodeObjectCreateExpression(typeof(XmlEmbeddedResourceResolver))
         };

			CodeTryCatchFinallyStatement trySt = new CodeTryCatchFinallyStatement { 
            TryStatements = {
               new CodeAssignStatement {
                  Left = new CodeVariableReferenceExpression(sourceVar.Name),
                  Right = new CodeCastExpression {
                     TargetType = new CodeTypeReference(typeof(Stream)),
                     Expression = new CodeMethodInvokeExpression {
                        Method = new CodeMethodReferenceExpression {
                           MethodName = "GetEntity",
                           TargetObject = new CodeVariableReferenceExpression(resolverVar.Name)
                        },
                        Parameters = {
                           new CodeVariableReferenceExpression(sourceUriVar.Name),
                           new CodePrimitiveExpression(null),
                           new CodeTypeOfExpression(typeof(Stream))
                        }
                     }
                  }
               }
            }
         };

			CodeVariableDeclarationStatement optionsVar = new CodeVariableDeclarationStatement {
            Name = "options",
            Type = new CodeTypeReference(typeof(XsltCompileOptions)),
         };
			optionsVar.InitExpression = new CodeObjectCreateExpression (optionsVar.Type);

			trySt.TryStatements.Add (optionsVar);
			trySt.TryStatements.Add (new CodeAssignStatement {
            Left = new CodePropertyReferenceExpression {
               PropertyName = "BaseUri",
               TargetObject = new CodeVariableReferenceExpression(optionsVar.Name)
            },
            Right = new CodeVariableReferenceExpression(sourceUriVar.Name)
         });
			trySt.TryStatements.Add (new CodeAssignStatement {
            Left = new CodeFieldReferenceExpression {
               FieldName = executableField.Name,
               TargetObject = thisType
//.........这里部分代码省略.........
开发者ID:nuxleus,项目名称:Nuxleus,代码行数:101,代码来源:SchematronValidatorCodeDomTreeGenerator.cs

示例12: AddToTimeSpanFunction


//.........这里部分代码省略.........
            cboe.Left = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(tsParam),"Length");
            cboe.Right = new CodePrimitiveExpression(DMTF_DATETIME_STR_LENGTH);
            cboe.Operator = CodeBinaryOperatorType.IdentityInequality;

            cis = new CodeConditionStatement();
            cis.Condition = cboe;
            cis.TrueStatements.Add(new CodeThrowExceptionStatement(codeThrowException));

            cmmts.Statements.Add(cis);
            
            /*
                if(dmtfTimespan.Substring(21,4) != ":000")
                {
                    throw new System.ArgumentOutOfRangeException();
                }
            */
            
            CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
            cmie.Method = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(tsParam),"Substring");
            cmie.Parameters.Add(new CodePrimitiveExpression(21));
            cmie.Parameters.Add(new CodePrimitiveExpression(4));

            cboe = new CodeBinaryOperatorExpression();
            cboe.Left = cmie;
            cboe.Right = new CodePrimitiveExpression(":000");
            cboe.Operator = CodeBinaryOperatorType.IdentityInequality;

            cis = new CodeConditionStatement();
            cis.Condition = cboe;
            cis.TrueStatements.Add(new CodeThrowExceptionStatement(codeThrowException));

            cmmts.Statements.Add(cis);

            CodeTryCatchFinallyStatement tryblock = new CodeTryCatchFinallyStatement();

            /*
                string tempString = System.String.Empty;
            */

            string strTemp = "tempString";
            tryblock.TryStatements.Add(new CodeVariableDeclarationStatement(new CodeTypeReference("System.String"),strTemp,
                new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("System.String"),"Empty")));
            /*
                tempString = dmtfTimespan.Substring(0, 8);
                days = System.Int32.Parse(tempString);

                tempString = dmtfTimespan.Substring(8, 2);
                hours = System.Int32.Parse(tempString);

                tempString = dmtfTimespan.Substring(10, 2);
                minutes = System.Int32.Parse(tempString);

                tempString = dmtfTimespan.Substring(12, 2);
                seconds = System.Int32.Parse(tempString);
            */

            ToTimeSpanHelper(0,8,days,tryblock.TryStatements);
            ToTimeSpanHelper(8,2,hours,tryblock.TryStatements);
            ToTimeSpanHelper(10,2,minutes,tryblock.TryStatements);
            ToTimeSpanHelper(12,2,seconds,tryblock.TryStatements);

            /*
                tempString = dmtfTimespan.Substring(15, 6);
            */

            cmie = new CodeMethodInvokeExpression();
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:67,代码来源:WMIGenerator.cs

示例13: AddToDateTimeFunction


//.........这里部分代码省略.........
                    throw new System.ArgumentOutOfRangeException();
                }
            */

            cboe = new CodeBinaryOperatorExpression();
            cboe.Left = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(dmtf),"Length");
            cboe.Right = new CodePrimitiveExpression(0);
            cboe.Operator = CodeBinaryOperatorType.ValueEquality;

            cis = new CodeConditionStatement();
            cis.Condition = cboe;

            cis.TrueStatements.Add(new CodeThrowExceptionStatement(codeThrowException));

            cmmdt.Statements.Add(cis);

            /*
                if (str.Length != DMTF_DATETIME_STR_LENGTH )
                {
                    throw new System.ArgumentOutOfRangeException();
                }
            */
            cboe = new CodeBinaryOperatorExpression();
            cboe.Left = new CodePropertyReferenceExpression(new CodeVariableReferenceExpression(dmtf),"Length");
            cboe.Right = new CodePrimitiveExpression(DMTF_DATETIME_STR_LENGTH);
            cboe.Operator = CodeBinaryOperatorType.IdentityInequality;

            cis = new CodeConditionStatement();
            cis.Condition = cboe;
            cis.TrueStatements.Add(new CodeThrowExceptionStatement(codeThrowException));

            cmmdt.Statements.Add(cis);

            CodeTryCatchFinallyStatement tryblock = new CodeTryCatchFinallyStatement();
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"****",tempStr,dmtf,year,0,4);
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"**",tempStr,dmtf,month,4,2);
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"**",tempStr,dmtf,day,6,2);
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"**",tempStr,dmtf,hour,8,2);
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"**",tempStr,dmtf,minute,10,2);
            DateTimeConversionFunctionHelper(tryblock.TryStatements,"**",tempStr,dmtf,second,12,2);

            /*
                tempString = dmtf.Substring(15, 6);
                if (("******" != tempString)) 
                {
                    ticks = (System.Int64.Parse(tempString)) * (System.TimeSpan.TicksPerMillisecond/1000);
                }
            */

            CodeMethodReferenceExpression  cmre = new CodeMethodReferenceExpression(new CodeVariableReferenceExpression(dmtf),"Substring");
            CodeMethodInvokeExpression cmie = new CodeMethodInvokeExpression();
            cmie.Method = cmre;
            cmie.Parameters.Add(new CodePrimitiveExpression(15));
            cmie.Parameters.Add(new CodePrimitiveExpression(6));
            tryblock.TryStatements.Add(new CodeAssignStatement(new CodeVariableReferenceExpression(tempStr), cmie));


            cboe = new CodeBinaryOperatorExpression();
            cboe.Left = new CodePrimitiveExpression("******");
            cboe.Right = new CodeVariableReferenceExpression(tempStr);
            cboe.Operator = CodeBinaryOperatorType.IdentityInequality;
            cis = new CodeConditionStatement();
            cis.Condition = cboe;

            CodeMethodReferenceExpression  cmre1 = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression("System.Int64"),"Parse");
            CodeMethodInvokeExpression cmie1 = new CodeMethodInvokeExpression();
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:67,代码来源:WMIGenerator.cs

示例14: VisitCodeTryCatchFinallyStatement

		void VisitCodeTryCatchFinallyStatement(CodeTryCatchFinallyStatement tryStatement)
		{
			WriteLine("VisitCodeTryCatchFinallyStatement");
			using (IDisposable currentLevel = Indentation.IncrementLevel()) {
				WriteLine("Try statements follow: Count: " + tryStatement.TryStatements.Count);
				foreach (CodeStatement statement in tryStatement.TryStatements) {
					VisitCodeStatement(statement);
				}
				
				WriteLine("Catch clauses follow: Count: " + tryStatement.CatchClauses.Count);
				foreach (CodeCatchClause catchClause in tryStatement.CatchClauses) {
					VisitCodeCatchClause(catchClause);
				}				
				
				WriteLine("Finally statements follow: Count: " + tryStatement.FinallyStatements);
				foreach (CodeStatement statement in tryStatement.FinallyStatements) {
					VisitCodeStatement(statement);
				}				
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:20,代码来源:CodeDomVisitor.cs

示例15: WriteHookupMethods

 private void WriteHookupMethods(CodeTypeDeclaration cls)
 {
     if (this.axctlEventsType != null)
     {
         CodeMemberMethod method = new CodeMemberMethod {
             Name = "CreateSink",
             Attributes = MemberAttributes.Family | MemberAttributes.Override
         };
         CodeObjectCreateExpression expression = new CodeObjectCreateExpression(this.axctl + "EventMulticaster", new CodeExpression[0]);
         expression.Parameters.Add(new CodeThisReferenceExpression());
         CodeAssignStatement statement = new CodeAssignStatement(this.multicasterRef, expression);
         CodeObjectCreateExpression expression2 = new CodeObjectCreateExpression(typeof(AxHost.ConnectionPointCookie).FullName, new CodeExpression[0]);
         expression2.Parameters.Add(this.memIfaceRef);
         expression2.Parameters.Add(this.multicasterRef);
         expression2.Parameters.Add(new CodeTypeOfExpression(this.axctlEvents));
         CodeAssignStatement statement2 = new CodeAssignStatement(this.cookieRef, expression2);
         CodeTryCatchFinallyStatement statement3 = new CodeTryCatchFinallyStatement();
         statement3.TryStatements.Add(statement);
         statement3.TryStatements.Add(statement2);
         statement3.CatchClauses.Add(new CodeCatchClause("", new CodeTypeReference(typeof(Exception))));
         method.Statements.Add(statement3);
         cls.Members.Add(method);
         CodeMemberMethod method2 = new CodeMemberMethod {
             Name = "DetachSink",
             Attributes = MemberAttributes.Family | MemberAttributes.Override
         };
         CodeFieldReferenceExpression targetObject = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), this.cookie);
         CodeMethodInvokeExpression expression4 = new CodeMethodInvokeExpression(targetObject, "Disconnect", new CodeExpression[0]);
         statement3 = new CodeTryCatchFinallyStatement();
         statement3.TryStatements.Add(expression4);
         statement3.CatchClauses.Add(new CodeCatchClause("", new CodeTypeReference(typeof(Exception))));
         method2.Statements.Add(statement3);
         cls.Members.Add(method2);
     }
     CodeMemberMethod method3 = new CodeMemberMethod {
         Name = "AttachInterfaces",
         Attributes = MemberAttributes.Family | MemberAttributes.Override
     };
     CodeCastExpression right = new CodeCastExpression(this.axctlType.FullName, new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetOcx", new CodeExpression[0]));
     CodeAssignStatement statement4 = new CodeAssignStatement(this.memIfaceRef, right);
     CodeTryCatchFinallyStatement statement5 = new CodeTryCatchFinallyStatement();
     statement5.TryStatements.Add(statement4);
     statement5.CatchClauses.Add(new CodeCatchClause("", new CodeTypeReference(typeof(Exception))));
     method3.Statements.Add(statement5);
     cls.Members.Add(method3);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:AxWrapperGen.cs


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