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


C# CodeStatementCollection.Cast方法代码示例

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


在下文中一共展示了CodeStatementCollection.Cast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryCatchSend

 public virtual void TryCatchSend(CodeStatementCollection statements, CodeVariableReferenceExpression varrefSendHandle, CodeStatementCollection statementsTrySend)
 {
     CodeTryCatchFinallyStatement trycatchSend = new CodeTryCatchFinallyStatement(
         statementsTrySend.Cast<CodeStatement>().ToArray(),
         new CodeCatchClause[] { },
         new CodeStatement[] // Finally
         {
             // Dispose in finally block.
             new CodeConditionStatement(new CodeBinaryOperatorExpression(varrefSendHandle, CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)),
                 new CodeExpressionStatement(new CodeMethodInvokeExpression(varrefSendHandle, "Dispose"))
             )
         }
     );
     statements.Add(trycatchSend);
 }
开发者ID:jean-edouard,项目名称:win-tools,代码行数:15,代码来源:MarshalBuilderHelper.cs

示例2: ReceiveMessage

        public virtual CodeTryCatchFinallyStatement ReceiveMessage(string methodName, CodeStatementCollection statementsTryRecv)
        {
            CodeTryCatchFinallyStatement trycatchReceive = new CodeTryCatchFinallyStatement(
                new CodeStatement[]
                {
                    // ReceiveMessage
                    this.ReceiveMessage(),
                    // * if (((this.result == 0) && (msgHandleResp != null))) // If received message ok
                    new CodeConditionStatement(
                        new CodeBinaryOperatorExpression(
                            exprResultOk,
                            CodeBinaryOperatorType.BooleanAnd,
                            this.IfResponseHandleNotNull()
                        )
                        ,new CodeStatement[] // True statements
                        {
                            // * if ((msgResp.Data.typefield.type == Udbus.Core.dbus_msg_type.DBUS_TYPE_ERROR))
                            new CodeConditionStatement(
                                this.IfResponseIsDbusError()
                                ,new CodeStatement[]
                                {
                                    // * throw Udbus.Core.Exceptions.UdbusMessageMethodErrorException.Create("<method_name>", this.ConnectionParameters, msgStructResp);
                                    this.ThrowMethodErrorException(methodName)
                                }
                                ,statementsTryRecv.Cast<CodeStatement>().ToArray() // False statements
                            )
                        }
                        ,new CodeStatement[] // False statements
                        {
                            // * throw Udbus.Core.Exceptions.UdbusMethodReceiveException.Create("<method_name>", this.result, this.ConnectionParameters);
                            this.ThrowMethodReceiveException(methodName)
                        }
                    )

                },
                new CodeCatchClause[] { },
                new CodeStatement[] // Finally
                {
                    new CodeConditionStatement(
                        compResponseOk, new CodeExpressionStatement(new CodeMethodInvokeExpression(varrefResponseMessagePair, "Dispose"))
                    )
                }
            );
            return trycatchReceive;
        }
开发者ID:jean-edouard,项目名称:win-tools,代码行数:45,代码来源:MarshalBuilderHelper.cs

示例3: VisitCodeStatementCollection

 /// <summary>
 /// Visits a <see cref="CodeStatementCollection"/>.
 /// </summary>
 /// <param name="codeStatementCollection">The <see cref="CodeStatementCollection"/> to visit.</param>
 protected virtual void VisitCodeStatementCollection(CodeStatementCollection codeStatementCollection)
 {
     // Visit all of the CodeStatement items in the collection.
     foreach (CodeStatement item in codeStatementCollection.Cast<CodeStatement>())
     {
         this.VisitCodeStatement(item);
     }
 }
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:12,代码来源:CodeDomVisitor.cs

示例4: AssignResults

        public virtual void AssignResults(CodeStatementCollection statementsTryRecv
            , CodeConditionStatement condOut, CodeConditionStatement condOutIter
            , CodeStatementCollection stmtsFinishResult, CodeThrowExceptionStatement throwargOutPrev
            
            , string idlMethodName, ref int nOutArgCounter
            )
        {
            if (condOut != null) // If there are out parameters
            {
                if (stmtsFinishResult.Count > 0) // If there's any out result parameters
                {
                    // Assign if successful.
                    condOutIter.TrueStatements.Add(new CodeConditionStatement(
                        // * if (this.result == 0)
                        exprResultOk,
                        stmtsFinishResult.Cast<CodeStatement>().ToArray() // True statements
                        , new CodeStatement[] // False statements
                        {
                            throwargOutPrev
                        }
                    ));

                } // Ends if there's any out result parameters

                // Add the root condition variable.
                statementsTryRecv.Add(condOut);

            } // Ends if there are out parameters
        }
开发者ID:jean-edouard,项目名称:win-tools,代码行数:29,代码来源:MarshalBuilderHelper.cs

示例5: MakeSignalParameters

        static public void MakeSignalParameters(CodeTypeDeclaration typedeclArgs,
            CodeTypeFactory codetypefactoryOut,
            Udbus.Parsing.CodeMemberDeferredClassHolder declarationHolder,
            IDLInterface idlIntf,
            string methodName,
            string idlSignalName,
            IList<IDLSignalArgument> arguments,
            CodeParameterDeclarationExpressionCollection parameters,
            CodeStatementCollection statements,
            Udbus.Parsing.BuildContext context,
            MarshalBuilderHelper codebuilder)
        {
            CodeStatementCollection statementsTryRecv = new CodeStatementCollection();
            int nOutArgCounter = 0;
            List<CodeMethodInvokeExpression> invokemethodsBuild = new List<CodeMethodInvokeExpression>();
            CodeConditionStatement condOut = null; // Root if statement for out parameters.
            CodeConditionStatement condOutIter = null; // Most nested if statement for out parameters.
            CodeStatementCollection stmtsFinishResult = new CodeStatementCollection();
            CodeTypeReference typerefParamIter = CodeBuilderCommon.typerefUnknownParameters;
            string argNameIter = arguments != null && arguments.Count > 0 ? arguments[0].Name : "UnknownParameters";

            CodeThrowExceptionStatement throwargOutPrev = codebuilder.CreateArgumentOutException(idlSignalName);

            // WAXME
            //CodeConstructor constructorArgs = new CodeConstructor();
            //constructorArgs.Attributes = MemberAttributes.Public;
            foreach (IDLSignalArgument idlSignalArg in arguments)
            {
                argNameIter = idlSignalArg.Name;

                // Parse the type string for the argument, creating required structs as we go, and returning a type for the argument.
                //Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLMethodArgumentTypeNameBuilder(idlIntf, idlMethod, idlMethodArg);
                Udbus.Parsing.IDLArgumentTypeNameBuilderBase nameBuilder = new IDLArgumentTypeNameBuilder(idlIntf, methodName);
                ParamCodeTypeHolderMarshalBase paramtypeHolder = null;
                CodeTypeReference typerefParam = null;
                if (condOut == null)
                {
                    codebuilder.PrefixOutParams(ref condOut, ref condOutIter, idlSignalName, ref nOutArgCounter, ref throwargOutPrev);
                }

                // Handle the signal argument in the message.
                CodeConditionStatement condVarResult;
                codebuilder.MakeOutArgument(statements
                    , stmtsFinishResult
                    , idlSignalName
                    , codetypefactoryOut // Yeah I messed up the naming
                    , ref nOutArgCounter
                    , context
                    , ref throwargOutPrev
                    , idlSignalArg
                    , nameBuilder
                    , ref paramtypeHolder
                    , ref typerefParam
                    , out condVarResult
                );

                codebuilder.StoreCondIterator(ref condOut, ref condOutIter, condVarResult);

                // WAXME
                // Add a field to the <signal>Args class.
                //string argFieldName = CodeBuilderCommon.GetSignalArgFieldName(idlSignalArg.Name);
                //CodeFieldReferenceExpression fielrefdRefArgField = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), argFieldName);
                //typedeclArgs.Members.Add(new CodeMemberField(paramtypeHolder.paramtype.CodeType, argFieldName));
                //CodeMemberProperty propArgField = new CodeMemberProperty();
                //propArgField.Attributes = MemberAttributes.Public | MemberAttributes.Final;
                //propArgField.Type = paramtypeHolder.paramtype.CodeType;
                //propArgField.Name = PropertyNameFromFieldName(argFieldName);
                //propArgField.GetStatements.Add(new CodeMethodReturnStatement(fielrefdRefArgField));
                //typedeclArgs.Members.Add(propArgField);
                //constructorArgs.Parameters.Add(new CodeParameterDeclarationExpression(paramtypeHolder.paramtype.CodeType, argFieldName));
                //// * this.<signal_arg> = <signal_arg>;
                //constructorArgs.Statements.Add(new CodeAssignStatement(fielrefdRefArgField, new CodeArgumentReferenceExpression(argFieldName)));

            } // Ends loop over arguments

            //typedeclArgs.Members.Add(constructorArgs);

            codebuilder.AssignResults(statementsTryRecv, condOut, condOutIter, stmtsFinishResult, throwargOutPrev
                , idlSignalName, ref nOutArgCounter
            );
            List<CodeStatement> statementsReponse = new List<CodeStatement>();

            // Now receive the response.
            // Create message reader.
            // * Udbus.Core.UdbusMessageReader reader = new Udbus.Core.UdbusMessageReader(msgHandleResp);
            statementsTryRecv.Insert(0, codebuilder.CreateMessageReader());
            statementsReponse.AddRange(statementsTryRecv.Cast<CodeStatement>());
            statements.Add(new CodeConditionStatement(exprResultOk, statementsReponse.ToArray()));
        }
开发者ID:rneilturner,项目名称:win-tools,代码行数:89,代码来源:MarshalBuilder.cs


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