private static void GenerateHostResolveParameterValueLookup(string nameValue, CodeMemberField field, CodeStatementCollection statements, CodeVariableReferenceExpression valueAcquired, CodeTypeReference typeReference, CodeStatement setValueAcquired, string typeValue)
        {
            CodePropertyReferenceExpression  callSite    = new CodeThisReferenceExpression().Prop("Host");
            CodeVariableDeclarationStatement declaration = new CodeVariableDeclarationStatement(typeof(string).Ref(), "parameterValue", callSite.Call("ResolveParameterValue", new CodeExpression[] { "Property".Prim(), "PropertyDirectiveProcessor".Prim(), nameValue.Prim() }));
            CodeVariableReferenceExpression  expression2 = declaration.Ref();
            CodeVariableDeclarationStatement statement2  = new CodeVariableDeclarationStatement(typeof(TypeConverter).Ref(), "tc", typeof(TypeDescriptor).Expr().Call("GetConverter", new CodeExpression[] { new CodeTypeOfExpression(typeReference) }));

            statements.Add(new CodeConditionStatement(valueAcquired.VEquals(false.Prim()), new CodeStatement[] { declaration, new CodeConditionStatement(typeof(string).Expr().Call("IsNullOrEmpty", new CodeExpression[] { expression2 }).VEquals(false.Prim()), new CodeStatement[] { statement2, new CodeConditionStatement(statement2.Ref().NotNull().And(statement2.Ref().Call("CanConvertFrom", new CodeExpression[] { new CodeTypeOfExpression(typeof(string).Ref()) })), new CodeStatement[] { field.Ref().Assign(new CodeCastExpression(typeReference, statement2.Ref().Call("ConvertFrom", new CodeExpression[] { expression2 }))), setValueAcquired }, new CodeStatement[] { GenerateReportTypeMismatch(nameValue, typeValue) }) }) }));
        }
        private static void GenerateCallContextLookup(string nameValue, CodeMemberField field, CodeStatementCollection statements, CodeVariableReferenceExpression valueAcquired, CodeTypeReference typeReference, string typeValue)
        {
            CodeVariableDeclarationStatement codeVariableDeclarationStatement = typeof(object).Decl("data", typeof(CallContext).Expr().Call("LogicalGetData", nameValue.Prim()));
            CodeVariableReferenceExpression  codeVariableReferenceExpression  = codeVariableDeclarationStatement.Ref();
            CodeAssignStatement    codeAssignStatement    = field.Ref().Assign(typeReference.Cast(codeVariableReferenceExpression));
            CodeConditionStatement codeConditionStatement = new CodeConditionStatement(codeVariableReferenceExpression.NotNull(), codeAssignStatement);

            statements.Add(new CodeConditionStatement(valueAcquired.VEquals(false.Prim()), codeVariableDeclarationStatement, codeConditionStatement));
        }
        private static void GenerateCallContextLookup(string nameValue, CodeMemberField field, CodeStatementCollection statements, CodeVariableReferenceExpression valueAcquired, CodeTypeReference typeReference, string typeValue)
        {
            CodeVariableDeclarationStatement declaration = typeof(object).Decl("data", typeof(CallContext).Expr().Call("LogicalGetData", new CodeExpression[] { nameValue.Prim() }));
            CodeVariableReferenceExpression  expression  = declaration.Ref();
            CodeAssignStatement    statement2            = field.Ref().Assign(typeReference.Cast(expression));
            CodeConditionStatement statement3            = new CodeConditionStatement(expression.NotNull(), new CodeStatement[] { GenerateTypeMismatchCheck(expression, nameValue, typeReference, typeValue, new CodeStatement[] { statement2 }) });

            statements.Add(new CodeConditionStatement(valueAcquired.VEquals(false.Prim()), new CodeStatement[] { declaration, statement3 }));
        }
Exemple #4
0
        private static void ProvidePushIndentMethod(CodeTypeMemberCollection members, CodeMemberField currentIndent, CodeMemberProperty indentLengths)
        {
            CodeVariableReferenceExpression codeVariableReferenceExpression = new CodeVariableReferenceExpression("indent");
            CodeMemberMethod codeMemberMethod = CodeDomHelpers.CreateMethod(null, "PushIndent", "Increase the indent", (MemberAttributes)24578, new CodeConditionStatement(codeVariableReferenceExpression.VEquals(CodeDomHelpers.nullEx), new CodeThrowExceptionStatement(typeof(ArgumentNullException).New("indent".Prim()))), currentIndent.Ref().Assign(currentIndent.Ref().Add(codeVariableReferenceExpression)), indentLengths.Ref().CallS("Add", codeVariableReferenceExpression.Prop("Length")));

            codeMemberMethod.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(string)), "indent"));
            members.Add(codeMemberMethod);
        }
        private static void ProvidePushIndentMethod(CodeTypeMemberCollection members, CodeMemberField currentIndent, CodeMemberProperty indentLengths)
        {
            CodeVariableReferenceExpression lhs = new CodeVariableReferenceExpression("indent");
            CodeMemberMethod method             = CodeDomHelpers.CreateMethod(null, "PushIndent", "Increase the indent", MemberAttributes.Public | MemberAttributes.Final, new CodeObject[] { new CodeConditionStatement(lhs.VEquals(CodeDomHelpers.nullEx), new CodeStatement[] { new CodeThrowExceptionStatement(typeof(ArgumentNullException).New(new CodeExpression[] { "indent".Prim() })) }), currentIndent.Ref().Assign(currentIndent.Ref().Add(lhs)), indentLengths.Ref().CallS("Add", new CodeExpression[] { lhs.Prop("Length") }) });

            method.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(string)), "indent"));
            members.Add(method);
        }