Beispiel #1
0
        private CodeExpression BuildProxy(CodeStatementCollection statements, MethodInfo method)
        {
            Type   type = this.proxy.GetType();
            string name = CodeIdentifier.MakeCamel(type.Name);

            if (this.proxySetting == ProxySettings.AllProperties)
            {
                return(this.BuildClass(statements, name, this.proxy));
            }
            CodeVariableDeclarationStatement statement = new CodeVariableDeclarationStatement(type.Name, name);

            statement.InitExpression = new CodeObjectCreateExpression(type.FullName, new CodeExpression[0]);
            statements.Add(statement);
            CodeExpression targetObject = new CodeVariableReferenceExpression(name);

            FieldInfo[] soapHeaders = null;
            if (this.proxySetting == ProxySettings.RequiredHeaders)
            {
                soapHeaders = MethodProperty.GetSoapHeaders(method, true);
            }
            else
            {
                soapHeaders = type.GetFields();
            }
            for (int i = 0; i < soapHeaders.Length; i++)
            {
                FieldInfo info = soapHeaders[i];
                if (typeof(SoapHeader).IsAssignableFrom(info.FieldType))
                {
                    CodeExpression left  = new CodeFieldReferenceExpression(targetObject, info.Name);
                    CodeExpression right = this.BuildObject(statements, info.Name, info.GetValue(this.proxy));
                    statements.Add(new CodeAssignStatement(left, right));
                }
            }
            return(targetObject);
        }
Beispiel #2
0
        private CodeExpression BuildProxy(CodeStatementCollection statements, MethodInfo method)
        {
            Type   type1 = proxy.GetType();
            string text1 = CodeIdentifier.MakeCamel(type1.Name);

            if (proxySetting == ProxySettings.AllProperties)
            {
                return(BuildClass(statements, text1, proxy));
            }
            CodeVariableDeclarationStatement statement1 = new CodeVariableDeclarationStatement(type1.Name, text1);

            statement1.InitExpression = new CodeObjectCreateExpression(type1.FullName, new CodeExpression[0]);
            statements.Add(statement1);
            CodeExpression expression1 = new CodeVariableReferenceExpression(text1);

            FieldInfo[] infoArray1 = null;
            if (proxySetting == ProxySettings.RequiredHeaders)
            {
                infoArray1 = MethodProperty.GetSoapHeaders(method, true);
            }
            else
            {
                infoArray1 = type1.GetFields();
            }
            for (int num1 = 0; num1 < infoArray1.Length; num1++)
            {
                FieldInfo info1 = infoArray1[num1];
                if (typeof(SoapHeader).IsAssignableFrom(info1.FieldType))
                {
                    CodeExpression expression2 = new CodeFieldReferenceExpression(expression1, info1.Name);
                    CodeExpression expression3 = BuildObject(statements, info1.Name, info1.GetValue(proxy));
                    statements.Add(new CodeAssignStatement(expression2, expression3));
                }
            }
            return(expression1);
        }