AddRange() public method

public AddRange ( CodeStatement value ) : void
value CodeStatement
return void
Ejemplo n.º 1
0
        public CodeStatementCollection GenerateCodeInvocation( AssignActivity assignActivity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(assignActivity));

            invocationCodeCollection.AddRange(this.xslBuilder.Build(assignActivity.InputBindings));

            var variableToAssignReference = new CodeFieldReferenceExpression ( new CodeThisReferenceExpression (), VariableHelper.ToVariableName(assignActivity.VariableName));
            var codeInvocation = new CodeAssignStatement (variableToAssignReference, new CodeVariableReferenceExpression(VariableHelper.ToVariableName(assignActivity.VariableName)));
            invocationCodeCollection.Add(codeInvocation);
            return invocationCodeCollection;
        }
Ejemplo n.º 2
0
		public void Constructor1_Deny_Unrestricted ()
		{
			CodeStatementCollection coll = new CodeStatementCollection (array);
			coll.CopyTo (array, 0);
			Assert.AreEqual (1, coll.Add (cs), "Add");
			Assert.AreSame (cs, coll[0], "this[int]");
			coll.AddRange (array);
			coll.AddRange (coll);
			Assert.IsTrue (coll.Contains (cs), "Contains");
			Assert.AreEqual (0, coll.IndexOf (cs), "IndexOf");
			coll.Insert (0, cs);
			coll.Remove (cs);
		}
        public CodeStatementCollection GenerateCodeInvocation(WriteToLogActivity activity)
        {
            var invocationCodeCollection = new CodeStatementCollection();

            // add log
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(activity));
            //add the input
            invocationCodeCollection.AddRange(this.xslBuilder.Build(activity.InputBindings));

            //Add the logger call
            invocationCodeCollection.Add(this.GenerateLoggerCodeInvocation(activity));

            return invocationCodeCollection;
        }
        public CodeStatementCollection GenerateCodeInvocation(GenerateErrorActivity activity)
        {
            var invocationCodeCollection = new CodeStatementCollection();

            // add log
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(activity));
            //add the input
            invocationCodeCollection.AddRange(this.xslBuilder.Build(activity.InputBindings));

            // Add the exception Call
            invocationCodeCollection.Add(this.GenerateExceptionStatement(activity));

            return invocationCodeCollection;
        }
Ejemplo n.º 5
0
        private CodeStatementCollection GenerateCoreGroupMethod(GroupActivity groupActivity)
        {
            var invocationCodeCollection = new CodeStatementCollection();

            invocationCodeCollection.AddRange(this.coreProcessBuilder.GenerateStartCodeStatement(groupActivity.Transitions, "start", null, this.activityNameToServiceNameDictionnary));
            return invocationCodeCollection;
        }
Ejemplo n.º 6
0
        public CodeStatementCollection DefaultInvocationMethod(Activity activity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(activity));

            return invocationCodeCollection;
        }
		public PreshaderSrc(AsmListing listing, CodeStatementCollection statementCollection)
		{
			statements = new List<CodeStatement>();

			object[] paramsArray = new object[1];
			StringBuilder sb = new StringBuilder();

			foreach (AsmCommand cmd in listing.Commands)
			{
				
				MethodInfo method;
				if (!methodList.TryGetValue(cmd.Target, out method))
				{
					if (cmd.Target == "preshader")
						continue;

					throw new CompileException(string.Format("Error decoding PreShader: Unexpected command '{0}'", cmd.Target));
				}

				string[] args = new string[cmd.OpCount];
				for (int i = 0; i < cmd.OpCount; i++)
				{
					cmd.GetOp(i).ToString(sb);
					args[i] = sb.ToString();
					sb.Length = 0;
				}
				paramsArray[0] = args;

				method.Invoke(this, paramsArray);
			}

			statementCollection.AddRange(this.statements.ToArray());
		}
Ejemplo n.º 8
0
 public CodeStatementCollection DefaultInvocationMethod(Activity activity)
 {
     var activityServiceReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), VariableHelper.ToVariableName(activity.Name));
     var methodInvocation = new CodeMethodInvokeExpression(activityServiceReference, "Execute", new CodeExpression[] { });
     var invocationCodeCollection = new CodeStatementCollection();
     invocationCodeCollection.AddRange(LogActivity(activity));
     invocationCodeCollection.Add(methodInvocation);
     return invocationCodeCollection;
 }
Ejemplo n.º 9
0
        public CodeStatementCollection GenerateCodeInvocation( MapperActivity mapperActivity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            // Add the Log
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(mapperActivity));
            // Add the mapping
            invocationCodeCollection.AddRange(this.xslBuilder.Build(mapperActivity.InputBindings));

            // Add the invocation
            var variableReturnType = mapperActivity.XsdReference.Split(':')[1];
            var variableName = VariableHelper.ToVariableName(mapperActivity.Name);

            var parameter = new CodeVariableReferenceExpression(mapperActivity.Parameters[0].Name);

            var code = new CodeVariableDeclarationStatement (variableReturnType, variableName, parameter);

            invocationCodeCollection.Add(code);

            return invocationCodeCollection;
        }
        /// <summary>
        /// Serializes properties of a certain component.
        /// </summary>
        /// <param name="componentHolder">The parent expression that holds the instance.</param>
        /// <param name="instance">The component to take away the values from.</param>
        /// <returns>A collection of code statements initiating the properties of the given object to their values.</returns>
        public CodeStatementCollection SerializeProperties(CodeExpression componentHolder, object instance)
        {
            CodeStatementCollection statements = new CodeStatementCollection();

            // Iterate through properties and add property + value to statements.
            foreach (PropertyDescriptor property in GetMustSerializeProperties(instance))
            {
                statements.AddRange(SerializeProperty(componentHolder, instance, property));
            }

            return statements;
        }
        public CodeStatementCollection GenerateCodeInvocation(CallProcessActivity callProcessActivity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            // Add the Log
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(callProcessActivity));
            // Add the mapping
            invocationCodeCollection.AddRange(this.xslBuilder.Build(callProcessActivity.InputBindings));

            // Add the invocation
            var processToCallReference = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), VariableHelper.ToVariableName(callProcessActivity.TibcoProcessToCall.ProcessName));

            var parameters = DefaultActivityBuilder.GenerateParameters(callProcessActivity);

            // TODO : WARNING not sure the start method ProcessName is indeed START
            var methodInvocation = new CodeMethodInvokeExpression(processToCallReference, "Start", parameters);

            var code = new CodeVariableDeclarationStatement("var", VariableHelper.ToVariableName(callProcessActivity.Name), methodInvocation);

            invocationCodeCollection.Add(code);

            return invocationCodeCollection;
        }
Ejemplo n.º 12
0
        public CodeSwitchStatement(CodeExpression target, CodeSwitchOption[] options, params CodeStatement[] defaultStatements)
        {
            _target = target;
            _options = new CodeSwitchOptionCollection(OptionsChanged, options);

            foreach (CodeSwitchOption option in options)
            {
                option.SetTarget(_target);
            }

            _defaultStatements = base.FalseStatements;
            _defaultStatements.AddRange(defaultStatements);
            Refresh();
        }
        /// <summary>
        /// Serializes a specific property to code.
        /// </summary>
        /// <param name="instanceHolder">The parent expression that holds the instance.</param>
        /// <param name="instance">The instance to take away the values from.</param>
        /// <param name="property">The property to serialize.</param>
        /// <returns>A collection of code statements initiating the given property of the given object to its value.</returns>
        public CodeStatementCollection SerializeProperty(CodeExpression instanceHolder, object instance, PropertyDescriptor property)
        {
            CodeStatementCollection statements = new CodeStatementCollection();

            var propertyExpression = new CodePropertyReferenceExpression(
                    instanceHolder,
                    property.Name);

            object propertyValue = property.GetValue(instance);
            if (property.PropertyType.HasInterface(typeof(ICollection)))
            {
                // If collection, create property.Add(...) statements.
                statements.AddRange(CreateCollectionInitialization(propertyExpression, instance, property));
            }
            else if (CodeDomTypeFormatter.IsFormattableWithAssignment(property.PropertyType)) 
            {
                // else, create normal property = value statement.
                statements.Add(CreatePropertyAssignmentExpression(propertyExpression, instance, property));
            }

            if (!CodeDomTypeFormatter.IsFormattableWithAssignment(property.PropertyType))
            {
                // serialize child properties.
                if (property.PropertyType.IsValueType)
                {
                    // value types uses a temp var.to access properties.
                    statements.AddRange(CreateValueTypeInitialization(propertyExpression, instance, property));
                }
                else
                {
                    // access properties directly.
                    statements.AddRange(SerializeProperties(propertyExpression, propertyValue));
                }
            }

            return statements;
        }
Ejemplo n.º 14
0
        private CodeStatementCollection InvocationMethod(Activity activity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(activity));

            var groupActivity = (GroupActivity)activity;

            if (groupActivity.GroupType == GroupType.simpleGroup)
            {
                invocationCodeCollection.AddRange(this.GenerateCoreGroupMethod(groupActivity));
            }
            else
            {
                var forLoop = this.GenerateForLoop(groupActivity);
                invocationCodeCollection.Add(forLoop);
            }

            return invocationCodeCollection;
        }
Ejemplo n.º 15
0
        private CodeIterationStatement GenerateForLoop(GroupActivity groupActivity)
        {
            var coreGroupMethodStatement = new CodeStatementCollection();

            // put the current element in the declare variable
            // TODO convert the $Variable in variable like in Xpath
            CodeVariableDeclarationStatement iterationElementSlotDeclaration = new CodeVariableDeclarationStatement("var", groupActivity.IterationElementSlot, new CodeVariableReferenceExpression(groupActivity.Over + "[" + groupActivity.IndexSlot + "]"));
            coreGroupMethodStatement.Add(iterationElementSlotDeclaration);
            // get the core loop code
            coreGroupMethodStatement.AddRange(this.GenerateCoreGroupMethod(groupActivity));
            var array = new CodeStatement[coreGroupMethodStatement.Count];
            coreGroupMethodStatement.CopyTo(array, 0);

            // put it then in the loop
            CodeIterationStatement forLoop = new CodeIterationStatement(new CodeVariableDeclarationStatement(typeof(int), groupActivity.IndexSlot, new CodePrimitiveExpression(0)),
                new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression(groupActivity.IndexSlot), CodeBinaryOperatorType.LessThan, new CodeVariableReferenceExpression(groupActivity.Over + ".Lenght")),
                new CodeAssignStatement(new CodeVariableReferenceExpression(groupActivity.IndexSlot), new CodeBinaryOperatorExpression(new CodeVariableReferenceExpression(groupActivity.IndexSlot), CodeBinaryOperatorType.Add, new CodePrimitiveExpression(1))),
                array);
            return forLoop;
        }
Ejemplo n.º 16
0
        public CodeStatementCollection GenerateCodeInvocation(JavaActivity javaActivity)
        {
            var invocationCodeCollection = new CodeStatementCollection();
            invocationCodeCollection.AddRange(DefaultActivityBuilder.LogActivity(javaActivity));

            invocationCodeCollection.AddRange(this.xslBuilder.Build(javaActivity.InputBindings));

            var variableReturnType = new CodeTypeReference(javaActivity.PackageName + "." + javaActivity.FileName);
            var creation = new CodeObjectCreateExpression (variableReturnType, new CodeExpression[0]);

            string javaClassVariableName = VariableHelper.ToVariableName(javaActivity.FileName);
            var codeInvocation = new CodeVariableDeclarationStatement(variableReturnType, javaClassVariableName, creation);

            invocationCodeCollection.Add(codeInvocation);

            CodeVariableReferenceExpression javaClassReference = new CodeVariableReferenceExpression();
            javaClassReference.VariableName = javaClassVariableName;

            //add input to java class
            invocationCodeCollection.AddRange(this.GenerateInputCallOnJavaClass(javaActivity, javaClassReference));

            // add call ti invoke methode
            invocationCodeCollection.Add(this.GenerateInvokeCallOnJavaClass(javaClassReference));

            // instanciate the result class
            var activityReturnType = new CodeTypeReference(javaActivity.PackageName + "." + VariableHelper.ToClassName(javaActivity.Name));
            var creationActivityReturn = new CodeObjectCreateExpression (activityReturnType, new CodeExpression[0]);

            string activityClassVariableName = VariableHelper.ToVariableName(javaActivity.Name);
            var codeActivityInvocation = new CodeVariableDeclarationStatement(activityReturnType, activityClassVariableName, creationActivityReturn);

            invocationCodeCollection.Add(codeActivityInvocation);

            // retrieve the output
            CodeVariableReferenceExpression activityClassReference = new CodeVariableReferenceExpression();
            activityClassReference.VariableName = activityClassVariableName;

            invocationCodeCollection.AddRange(this.GenerateOutputCallOnJavaClass(javaActivity, javaClassReference, activityClassReference));

            return invocationCodeCollection;
        }
Ejemplo n.º 17
0
        private CodeStatement[] BuildIsParentStartElementStatements(string defaultNamespace, string fieldName, CodeNamespace codeNs, CodeTypeDeclaration codeType)
        {

            CodeStatementCollection statements = new CodeStatementCollection();
            bool addReadEndElement = fieldName == null ? true : false;
            bool addRead = fieldName == null ? true : false;

            // New up the local DataContract object
            if (fieldName == null)
            {
                fieldName = codeType.Name + "Field";
                statements.Add(CodeAssignNewObjectToVariableStatement(fieldName, codeType.Name));
            }

            // If the type is an enum build switch statement
            if (codeType.IsEnum)
            {
                statements.AddRange(BuildReaderEnumSwitchStatement(codeType.Name + "Field", codeType, "reader.ReadString()"));
            }
            else
            {
                // Build sort order list of attribute member indexes
                int[] sortOrder = CodeGenUtils.GetListOfAttributes(codeType.Members);

                // For attributes build parsing code
                // Attributes must be parsed before Reading elements (they are parsed first)
                foreach (int index in sortOrder)
                {
                    CodeMemberField memberField = (CodeMemberField)codeType.Members[index];

                    // Create IsAttribute parameters
                    CodeVariableReferenceExpression readerParam = new CodeVariableReferenceExpression("reader");
                    CodeVariableReferenceExpression nameParam = new CodeVariableReferenceExpression("\"" + memberField.Name + "\"");

                    if (memberField.Name == "AnyAttr")
                        statements.Add(BuildReadAnyAttributeStatement(fieldName, memberField));
                    else
                    {
                        statements.Add(
                            new CodeConditionStatement(
                                new CodeMethodInvokeExpression(
                                    null,
                                    "IsAttribute",
                                    new CodeExpression[] { readerParam, nameParam }
                                ),
                                memberField.Type.ArrayElementType == null ? BuildIsAttributeStatements(MemberType.Attribute, fieldName, memberField, codeNs) : BuildIsAttributeArrayStatements(MemberType.Attribute, fieldName, memberField, codeNs)
                            )
                        );
                    }
                }

                // Add Read to the IsParentStartElement conditional statements
                // reader.Read([FieldName]);
                // Since this method is recursive provisions restrict it to the first time through only.
                if (addRead)
                {
                    statements.Add(
                        new CodeMethodInvokeExpression(
                            new CodeVariableReferenceExpression("reader"),
                            "Read",
                            new CodeExpression[] { }
                        )
                    );
                }

                // Build sort order list of field member indexes
                sortOrder = CodeGenUtils.GetListOfMembers(codeType.Members);

                // For each field member build processing code
                foreach (int index in sortOrder)
                {
                    CodeMemberField memberField = (CodeMemberField)codeType.Members[index];

                    // If this a an Any element write the parsing calls here and forgo normal child processing
                    if (memberField.Type.BaseType == "XmlElement" && memberField.Name == "Any")
                    {
                        statements.Add(BuildReadAnyElementStatement(fieldName, memberField));
                    }
                    // Else if this is an Any element write the parsing calls here to forgo normal child
                    // processing. Create special reader
                    else if (!CodeGenUtils.IsNativeClrType(memberField.Type.BaseType))
                    {
                        statements.AddRange(BuildIsChildStartElementStatements(MemberType.Attribute, defaultNamespace, fieldName, memberField, codeNs));
                    }
                    else
                    {
                        

                        string nillable = CodeGenUtils.GetCustomAttributeArgumentValue("IsNillable", memberField.CustomAttributes);
                        bool isNillable = nillable == null || nillable == "false" ? false : true;

                        // Check to see if the element is required (i.e. minOccurs > 0)
                        string required = CodeGenUtils.GetCustomAttributeArgumentValue("IsRequired", memberField.CustomAttributes);
                        bool isRequired = required == null || required == "true" ? true : false;

                        // Build ReadStartObject if statement
                        CodeVariableReferenceExpression readerParam = new CodeVariableReferenceExpression("reader");
                        CodeVariableReferenceExpression nameParam = new CodeVariableReferenceExpression("\"" + memberField.Name + "\"");
                        CodePrimitiveExpression nillableParam = new CodePrimitiveExpression(isNillable);
                        CodePrimitiveExpression requiredParam = new CodePrimitiveExpression(isRequired);
                        CodeConditionStatement condition = new CodeConditionStatement(new CodeMethodInvokeExpression(null,
                            "IsChildStartElement",
                            new CodeExpression[] { readerParam, nameParam, nillableParam, requiredParam }),
                            // True condition code. Build read statements based on contract member type
                            BuildIsChildStartElementStatements(MemberType.Attribute, defaultNamespace, fieldName, memberField, codeNs)
                        );
                        statements.Add(condition);
                    }
                }
            }

            if (addReadEndElement)
            {
                // Build ReadEndElement statement
                statements.Add(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("reader"),
                    "ReadEndElement", new CodeExpression[] { }));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
Ejemplo n.º 18
0
        private CodeMemberMethod BuildNativeReadObjectMethod(string type, string typeName)
        {
            // Create ReadObject method
            CodeMemberMethod codeMemberMethod = new CodeMemberMethod();
            codeMemberMethod.Attributes = MemberAttributes.Public | MemberAttributes.Override;
            codeMemberMethod.ReturnType = new CodeTypeReference(typeof(object));
            codeMemberMethod.Name = "ReadObject";
            codeMemberMethod.Parameters.Add(new CodeParameterDeclarationExpression("XmlReader", "reader"));

            // Create temporary variable
            CodeVariableDeclarationStatement varDecl = new CodeVariableDeclarationStatement(type, typeName);
            if (varDecl.Type.ArrayElementType == null)
            {
                if (type == "System.String")
                    varDecl.InitExpression = new CodePrimitiveExpression(null);
            }
            else
                varDecl.InitExpression = new CodeArrayCreateExpression(type, new CodeExpression[] { });
            codeMemberMethod.Statements.Add(varDecl);

            // Create temporary member field used to generate read string code
            CodeMemberField memberField = new CodeMemberField(type, typeName);

            // Create conditional read statement
            CodeStatementCollection readStatements = new CodeStatementCollection();
            if (memberField.Type.ArrayElementType != null && CodeGenUtils.IsNativeClrType(memberField.Type.ArrayElementType.BaseType))
            {
                readStatements.AddRange(BuildReadStringArrayStatements(MemberType.Field, null, memberField));
            }
            // Else if this is a native type
            else if (Type.GetType(memberField.Type.BaseType) != null)
            {
                readStatements.Add(BuildReadStringStatement(MemberType.Field, null, memberField));
            }
            else
                throw new ArgumentException("Invalid native field type for schema item: " + memberField.Name);

            // Add ReadEndElement to condition statements
            readStatements.Add(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("reader"),
                "ReadEndElement", new CodeExpression[] { }));

            // Add native type return statement
            readStatements.Add(new CodeMethodReturnStatement(new CodeArgumentReferenceExpression(typeName)));

            // Convert statement collection to array
            CodeStatement[] readStatementArray = new CodeStatement[readStatements.Count];
            readStatements.CopyTo(readStatementArray, 0);

            // Build IsParentStartElement if statement
            CodeVariableReferenceExpression readerParam = new CodeVariableReferenceExpression("reader");
            CodePrimitiveExpression nillableParam = new CodePrimitiveExpression(false);
            CodePrimitiveExpression requiredParam = new CodePrimitiveExpression(true);
            CodeConditionStatement condition = new CodeConditionStatement(new CodeMethodInvokeExpression(null,
                "IsParentStartElement",
                new CodeExpression[] { readerParam, nillableParam, requiredParam }),
                readStatementArray);

            // Add condition
            codeMemberMethod.Statements.Add(condition);

            // Add null return statement
            codeMemberMethod.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(null)));

            return codeMemberMethod;
        }
Ejemplo n.º 19
0
        private CodeStatement[] BuildWriteChildElementStatements(string classRefName, CodeMemberField memberField)
        {
            CodeTypeReferenceExpression readerRef = new CodeTypeReferenceExpression("writer");
            CodeStatementCollection statements = new CodeStatementCollection();

            // If the messages uses Mtom encoding and this is a byte array special mtom processing applies
            if (m_encodingType == MessageEncodingType.Mtom && memberField.Type.ArrayElementType != null && memberField.Type.ArrayElementType.BaseType == "System.Byte")
            {
                // Increment the cid identifier
                ++m_cid;

                // BodyParts.Add(CreateNewBodyPart(ClassName.FieldName, "<cid@body>"));
                statements.Add(
                    new CodeMethodInvokeExpression(
                        new CodeVariableReferenceExpression("BodyParts"),
                        "Add",
                        new CodeExpression[] {
                            new CodeMethodInvokeExpression(
                                null,
                                "CreateNewBodyPart",
                                new CodeExpression[] {
                                    new CodeFieldReferenceExpression(
                                        new CodeVariableReferenceExpression(classRefName),
                                        memberField.Name
                                    ),
                                    new CodePrimitiveExpression("<" + m_cid.ToString() + "@body>")
                                }
                            )
                        }
                    )
                );
                // writer.WriteStartElement("xop", "Include", "http://www.w3.org/2004/08/xop/include");
                statements.Add(
                    new CodeMethodInvokeExpression(
                        new CodeVariableReferenceExpression("writer"),
                        "WriteStartElement",
                        new CodeExpression[] {
                            new CodePrimitiveExpression("xop"),
                            new CodePrimitiveExpression("Include"),
                            new CodePrimitiveExpression("http://www.w3.org/2004/08/xop/include")
                        }
                    )
                );
                // writer.WriteAttributeString(null, "href", null, "0@body");
                statements.Add(
                    new CodeMethodInvokeExpression(
                        new CodeVariableReferenceExpression("writer"),
                        "WriteAttributeString",
                        new CodeExpression[] {
                            new CodePrimitiveExpression(null),
                            new CodePrimitiveExpression("href"),
                            new CodePrimitiveExpression(null),
                            new CodePrimitiveExpression("cid:" + m_cid.ToString() + "@body")
                        }
                    )
                );
                // writer.WriteEndElement();
                statements.Add(
                    new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("writer"), "WriteEndElement")
                );
            }
            // If this is an any element create special reader
            else if (memberField.Type.BaseType == "XmlElement" && memberField.Name == "Any")
            {
                statements.Add(BuildWriteAnyElementStatement(classRefName, memberField));
            }
            // Else if this is a native array
            else if (memberField.Type.ArrayElementType != null && CodeGenUtils.IsNativeClrType(memberField.Type.ArrayElementType.BaseType))
            {
                statements.AddRange(BuildWriteArrayStatements(classRefName, memberField));
            }
            else
                statements.Add(BuildWriteStringStatement(classRefName, memberField));
            
            // If this is not an attribute add WriteEndElement statement
            if (CodeGenUtils.GetCustomAttributeArgumentValue("IsAttribute", memberField.CustomAttributes) == null)
            {
                CodeMethodInvokeExpression writeEndElementExp = new CodeMethodInvokeExpression(
                    readerRef,
                    "WriteEndElement",
                    new CodeExpression[] { });
                statements.Add(writeEndElementExp);
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
Ejemplo n.º 20
0
        private CodeStatement[] BuildWriteParentElementStatements(string defaultNamespace, string fieldName, CodeNamespace codeNs, CodeTypeDeclaration codeType)
        {
            CodeStatementCollection statements = new CodeStatementCollection();
            bool writeWriteEnd = fieldName == null ? true : false;

            // New up the local DataContract object
            fieldName = (fieldName == null) ? codeType.Name + "Field" : fieldName;

            // Build member write statements based on member type
            statements.AddRange(BuildWriteParentElementStatement(defaultNamespace, fieldName, codeNs, codeType));

            // If this is not a recursive call
            if (writeWriteEnd)
            {
                // Build WriteEndElement statement
                statements.Add(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("writer"),
                    "WriteEndElement", new CodeExpression[] { }));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;

        }
Ejemplo n.º 21
0
        private CodeStatementCollection BuildWriteParentElementStatement(string defaultNamespace, string fieldName, CodeNamespace codeNs, CodeTypeDeclaration codeType)
        {
            CodeStatementCollection statements = new CodeStatementCollection();

            // If the code type is an enum build reader.
            if (codeType.IsEnum)
            {
                statements.AddRange(BuildWriterEnumSwitchStatement(codeType));
            }
            else
            {
                // Sort member list.
                int[] sortOrder = CodeGenUtils.SortMemberTypes(codeType.Members);
                CodeMemberField codeField;
                
                // Build write statement for each member of the contract
                foreach (int index in sortOrder)
                {
                    codeField = (CodeMemberField)codeType.Members[index];
                 
                    // If this is an attribute build WriteAttribute element
                    if (CodeGenUtils.GetCustomAttributeArgumentValue("IsAttribute", codeField.CustomAttributes) == "True")
                    {
                        statements.Add(BuildWriteAttributeExpression(defaultNamespace, fieldName, codeField));
                    }
                    // Else if this is an anyAttibute element create special reader
                    else if (codeField.Type.BaseType != null && codeField.Name == "AnyAttr")
                    {
                        statements.Add(BuildWriteAnyAttributeStatement(fieldName, codeField));
                    }
                    // If this is a native schema type create WriteChildElement conditional statement
                    else if ((codeField.Type.ArrayElementType != null && CodeGenUtils.IsNativeClrType(codeField.Type.ArrayElementType.BaseType)) || Type.GetType(codeField.Type.BaseType) != null)
                    {
                        statements.Add(BuildWriteChildElementCondition(defaultNamespace, fieldName, codeField));
                    }
                    // If this is an any element create special reader
                    else if (codeField.Type.BaseType != null && codeField.Name == "Any")
                    {
                        statements.Add(BuildWriteAnyElementStatement(fieldName, codeField));
                    }
                    // Else Create new serializer and call it
                    else
                    {
                        // New up a DataContractSerialiser for this type
                        CodeVariableDeclarationStatement classDeclaration = new CodeVariableDeclarationStatement(codeField.Type.BaseType + "DataContractSerializer", codeField.Name + "DCS");

                        // Find the namespace of the member type which is required if there are nested namespaces in the data contract
                        string ns = CodeGenUtils.GetNamespaceFromType(m_codeNamespaces, codeField.Type.BaseType);

                        // use the default namespace if the field type was not found
                        if(string.IsNullOrEmpty(ns))
                        {
                            ns = defaultNamespace;
                        }

                        classDeclaration.InitExpression = new CodeObjectCreateExpression(
                            codeField.Type.BaseType + "DataContractSerializer",
                            new CodeExpression[] { new CodePrimitiveExpression(codeField.Name), new CodePrimitiveExpression(defaultNamespace), new CodePrimitiveExpression(ns) });
                        statements.Add(classDeclaration);

                        // If this is not an array process the element
                        if (codeField.Type.ArrayElementType == null)
                        {
                            // Build codeField[DCS].WriteObject(reader, [ClassName.FieldName); expression
                            CodeFieldReferenceExpression fieldRef = new CodeFieldReferenceExpression(
                                new CodeTypeReferenceExpression(fieldName),
                                codeField.Name);

                            CodeExpression writeExpression = new CodeMethodInvokeExpression(
                                new CodeTypeReferenceExpression(codeField.Name + "DCS"),
                                "WriteObject",
                                new CodeExpression[] { new CodeTypeReferenceExpression("writer"), fieldRef });

                            // Add processing expression
                            statements.Add(writeExpression);
                        }
                        // Else process an array of elements
                        else
                        {
                            statements.AddRange(BuildElementArrayWriteStatements(fieldName, codeField, defaultNamespace, codeNs));
                        }
                    }
                }
            }
            return statements;
        }
Ejemplo n.º 22
0
		private void SerializeContentProperty (IDesignerSerializationManager manager, object instance, 
						       PropertyDescriptor descriptor, CodeStatementCollection statements)
		{
			CodePropertyReferenceExpression propRef = new CodePropertyReferenceExpression ();
			propRef.PropertyName = descriptor.Name;
			object propertyValue = descriptor.GetValue (instance);

			ExpressionContext expressionCtx = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
			if (expressionCtx != null && expressionCtx.PresetValue == instance)
				propRef.TargetObject = expressionCtx.Expression;
			else
				propRef.TargetObject = base.SerializeToExpression (manager, instance);

			CodeDomSerializer serializer = manager.GetSerializer (propertyValue.GetType (), typeof (CodeDomSerializer)) as CodeDomSerializer;
			if (propRef.TargetObject != null && serializer != null) {
				manager.Context.Push (new ExpressionContext (propRef, propRef.GetType (), null, propertyValue));
				object serialized = serializer.Serialize (manager, propertyValue);
				manager.Context.Pop ();

				CodeStatementCollection serializedStatements = serialized as CodeStatementCollection;
				if (serializedStatements != null)
					statements.AddRange (serializedStatements);

				CodeStatement serializedStatement = serialized as CodeStatement;
				if (serializedStatement != null)
					statements.Add (serializedStatement);

				CodeExpression serializedExpr = serialized as CodeExpression;
				if (serializedExpr != null)
					statements.Add (new CodeAssignStatement (propRef, serializedExpr));
			}
		}
Ejemplo n.º 23
0
        private CodeMemberMethod BuildNativeWriteObjectMethod(string type, string typeName, CodeNamespace codeNs)
        {
            // Create WriteObject method
            CodeMemberMethod codeMemberMethod = new CodeMemberMethod();
            codeMemberMethod.Attributes = MemberAttributes.Public | MemberAttributes.Override;
            codeMemberMethod.ReturnType = new CodeTypeReference(typeof(void));
            codeMemberMethod.Name = "WriteObject";
            codeMemberMethod.Parameters.Add(new CodeParameterDeclarationExpression("XmlWriter", "writer"));
            codeMemberMethod.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "graph"));

            // Add type declaration
            CodeVariableDeclarationStatement declaration = new CodeVariableDeclarationStatement(type, typeName);
            declaration.InitExpression = new CodeCastExpression(type, new CodeVariableReferenceExpression("graph"));
            codeMemberMethod.Statements.Add(declaration);

            // Create temporary member field used to generate write string code
            CodeMemberField memberField = new CodeMemberField(type, typeName);

            // Create conditional write statement
            CodeStatementCollection writeStatements = new CodeStatementCollection();
            if (memberField.Type.ArrayElementType != null && CodeGenUtils.IsNativeClrType(memberField.Type.ArrayElementType.BaseType))
            {
                writeStatements.AddRange(BuildWriteArrayStatements(null, memberField));
            }
            // Else if this is a native type
            else if (Type.GetType(memberField.Type.BaseType) != null)
            {
                writeStatements.Add(BuildWriteStringStatement(null, memberField));
            }
            else
                throw new ArgumentException("Invalid native field type for schema item: " + memberField.Name);

            // Add WriteEndElement statement
            writeStatements.Add(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("writer"),
                "WriteEndElement", new CodeExpression[] { }));

            // Convert statement collection to array
            CodeStatement[] writeStatementArray = new CodeStatement[writeStatements.Count];
            writeStatements.CopyTo(writeStatementArray, 0);

            // Build WriteParentElement condition paramters
            CodeVariableReferenceExpression writerParam = new CodeVariableReferenceExpression("writer");
            CodePrimitiveExpression nillableParam = new CodePrimitiveExpression(false);
            CodePrimitiveExpression requiredParam = new CodePrimitiveExpression(true);
            CodeVariableReferenceExpression objectParam = new CodeVariableReferenceExpression("graph");

            // Build WriteParentElement condition statement
            CodeConditionStatement condition = new CodeConditionStatement(new CodeMethodInvokeExpression(null,
                "WriteParentElement",
                new CodeExpression[] { writerParam, nillableParam, requiredParam, objectParam }),
                // True condition code. Build read statements based on contract member type
                writeStatementArray
            );

            // Add condition
            codeMemberMethod.Statements.Add(condition);

            return codeMemberMethod;
        }
Ejemplo n.º 24
0
        private CodeStatement[] BuildIsAttributeStatements(MemberType memberType, string classRefName, CodeMemberField memberField, CodeNamespace codeNs)
        {
            CodeStatementCollection statements = new CodeStatementCollection();

            // If this is a native schema type create IsAttribute conditional statement
            if ((memberField.Type.ArrayElementType != null && Type.GetType(memberField.Type.ArrayElementType.BaseType) != null) || Type.GetType(memberField.Type.BaseType) != null)
            {
                statements.Add(BuildReadStringStatement(MemberType.Attribute, classRefName, memberField));
            }
            // Else if this is an enum type build switch
            else
            {
                // Attempt to get the enum type
                // Note: 2-16-09 - Changed code to get memberField.Type.BaseType instead of memberField.Name - Should
                // be going after the enum type not the complex field
                CodeTypeDeclaration enumType = CodeGenUtils.GetCodeType(memberField.Type.BaseType, codeNs);
                if (enumType == null || enumType.IsEnum == false)
                    throw new XmlException();
                statements.AddRange(BuildReaderEnumSwitchStatement(classRefName + "." + memberField.Name, enumType, "reader.Value"));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
Ejemplo n.º 25
0
        private CodeStatement[] BuildIsChildStartElementStatements(MemberType memberType, string defaultNamespace, string classRefName, CodeMemberField memberField, CodeNamespace codeNs)
        {
            CodeStatementCollection statements = new CodeStatementCollection();
            bool addReadEndElement = true;

            // Add Read to the IsChildStartElement conditional statements
            // reader.Read();
            CodeMethodInvokeExpression ReadExpression = new CodeMethodInvokeExpression(
                new CodeVariableReferenceExpression("reader"),
                "Read",
                new CodeExpression[] { }
            );
            statements.Add(ReadExpression);

            // If the messages uses Mtom encoding and this is a byte array special mtom processing applies
            if (m_encodingType == MessageEncodingType.Mtom && memberField.Type.ArrayElementType != null && memberField.Type.ArrayElementType.BaseType == "System.Byte")
            {
                // Build statements that retreive the Mtom message info
                statements.AddRange(BuildMtomReadStringStatements(memberType, classRefName, memberField));
            }
            else
            {

                // Else if this is a native schema array type create string array reader
                if (memberField.Type.ArrayElementType != null && CodeGenUtils.IsNativeClrType(memberField.Type.ArrayElementType.BaseType))
                {
                    statements.AddRange(BuildReadStringArrayStatements(MemberType.Field, classRefName, memberField));
                }
                // Else if this is a native type
                else if (Type.GetType(memberField.Type.BaseType) != null)
                {
                    statements.Add(BuildReadStringStatement(MemberType.Field, classRefName, memberField));
                }
                // Else if this is an enum type build switch
                else
                {
                    // If this is an enum  or nested object don't write ReadEndElement
                    addReadEndElement = false;

                    // Attempt to get the enum type
                    CodeTypeDeclaration enumType = CodeGenUtils.GetCodeType(memberField.Name, codeNs);
                    if (enumType != null && enumType.IsEnum == true)
                    {
                        statements.AddRange(BuildReaderEnumSwitchStatement(enumType.Name + "Field", enumType, "reader.Value"));
                    }
                    else
                    {
                        // Clear the ReadExpression from the statements collection if we get here
                        statements.Clear();

                        // New up a DataContractSerialiser for this type
                        CodeVariableDeclarationStatement classDeclaration = new CodeVariableDeclarationStatement(memberField.Type.BaseType + "DataContractSerializer", memberField.Name + "DCS");

                        // Find the namespace of the member type which is required if there are nested namespaces in the data contract
                        string ns = CodeGenUtils.GetNamespaceFromType(m_codeNamespaces, memberField.Type.BaseType);

                        // Use the default namespace if the member type's could not be found
                        if(string.IsNullOrEmpty(ns))
                        {
                           ns = defaultNamespace;
                        }

                        classDeclaration.InitExpression = new CodeObjectCreateExpression(
                            memberField.Type.BaseType + "DataContractSerializer",
                            new CodeExpression[] { new CodePrimitiveExpression(memberField.Name), new CodePrimitiveExpression(defaultNamespace), new CodePrimitiveExpression(ns) });

                        statements.Add(classDeclaration);

                        // Add data contract serializer used to process this type
                        if (memberField.Type.ArrayElementType == null)
                        {
                            // Build [ClassName].[FieldName] = codeField[DCS].ReadObject(reader); expression
                            CodeFieldReferenceExpression fieldRef = new CodeFieldReferenceExpression(
                                new CodeTypeReferenceExpression(classRefName),
                                memberField.Name);
                            CodeCastExpression readExpression = new CodeCastExpression(memberField.Type.BaseType,
                                new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(memberField.Name + "DCS"),
                                    "ReadObject",
                                    new CodeExpression[] { new CodeTypeReferenceExpression("reader") }));

                            CodeAssignStatement convertStatement = new CodeAssignStatement(fieldRef, readExpression);

                            // Add processing expression
                            statements.Add(convertStatement);
                        }
                        //Else if the base type is an array build array processor
                        else
                        {
                            statements.AddRange(BuildElementArrayReadStatements(classRefName, memberField, defaultNamespace, codeNs));
                        }
                    }
                }
            }

            // Build ReadEndElement statement
            if (addReadEndElement)
            {
                statements.Add(new CodeMethodInvokeExpression(new CodeVariableReferenceExpression("reader"),
                    "ReadEndElement", new CodeExpression[] { }));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
Ejemplo n.º 26
0
        private CodeStatement[] BuildWriteArrayStatements(string classRefName, CodeMemberField memberField)
        {
            CodeStatementCollection statements = new CodeStatementCollection();
            string tempListName = memberField.Name + "_List";

            // Add create tempList statement: string tempListName;
            CodeVariableDeclarationStatement declaration = new CodeVariableDeclarationStatement(typeof(string), tempListName);
            declaration.InitExpression = new CodePrimitiveExpression("");
            statements.Add(declaration);

            if (memberField.Type.ArrayElementType.BaseType == "System.Byte")
            {
                statements.Add(
                    new CodeConditionStatement(
                        new CodeFieldReferenceExpression(
                            new CodeThisReferenceExpression(),
                            "_CompressByteArrays"
                        ),
                        BuildWriteArrayStatementsBase64(tempListName, classRefName, memberField),
                        BuildWriteArrayStatementsNormal(tempListName, classRefName, memberField)
                    )
                );
            }
            else
            {
                statements.AddRange(BuildWriteArrayStatementsNormal(tempListName, classRefName, memberField));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
		protected override void AddPageTypeCtorStatements (CodeStatementCollection statements)
		{
			base.AddPageTypeCtorStatements (statements);

			CodeTypeReference uriType = new CodeTypeReference (typeof(Uri));

			CodeVariableDeclarationStatement procVar = new CodeVariableDeclarationStatement {
            Name = "proc",
            Type = new CodeTypeReference(typeof(IXQueryProcessor)),
            InitExpression = new CodeIndexerExpression {
               TargetObject = new CodePropertyReferenceExpression {
                  PropertyName = "XQuery",
                  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 virtualPathVar = new CodeVariableDeclarationStatement {
            Name = "virtualPath",
            Type = new CodeTypeReference(typeof(String)),
            InitExpression = new CodePrimitiveExpression(this.parser.AppRelativeVirtualPath)
         };

			CodeVariableDeclarationStatement sourceUriVar = new CodeVariableDeclarationStatement {
            Name = "sourceUri",
            Type = uriType,
            InitExpression = new CodeObjectCreateExpression {
               CreateType = uriType,
               Parameters = { 
                  new CodeMethodInvokeExpression {
                     Method = new CodeMethodReferenceExpression {
                        MethodName = "MapPath",
                        TargetObject = new CodeTypeReferenceExpression(typeof(HostingEnvironment))
                     },
                     Parameters = {
                        new CodeVariableReferenceExpression(virtualPathVar.Name)
                     }
                  },
                  new CodePropertyReferenceExpression {
                     PropertyName = "Absolute",
                     TargetObject = new CodeTypeReferenceExpression(typeof(UriKind))
                  }
               }
            }
         };
         
			CodeTryCatchFinallyStatement trySt = new CodeTryCatchFinallyStatement ();
			trySt.TryStatements.Add (new CodeAssignStatement {
            Left = new CodeVariableReferenceExpression(sourceVar.Name),
            Right = new CodeCastExpression {
               TargetType = new CodeTypeReference(typeof(Stream)),
               Expression = new CodeMethodInvokeExpression {
                  Method = new CodeMethodReferenceExpression {
                     MethodName = "OpenRead",
                     TargetObject = new CodeTypeReferenceExpression(typeof(File))
                  },
                  Parameters = { 
                     new CodePropertyReferenceExpression {
                        PropertyName = "LocalPath",
                        TargetObject = new CodeVariableReferenceExpression(sourceUriVar.Name)
                     }
                  }
               }
            }
         });

			CodeVariableDeclarationStatement optionsVar = new CodeVariableDeclarationStatement {
            Name = "options",
            Type = new CodeTypeReference(typeof(XQueryCompileOptions)),
         };
			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 = PageTypeReferenceExpression
            },
            Right = new CodeMethodInvokeExpression { 
               Method = new CodeMethodReferenceExpression {
                  MethodName = "Compile",
                  TargetObject = new CodeVariableReferenceExpression(procVar.Name)
               },
               Parameters = {
                  new CodeVariableReferenceExpression(sourceVar.Name),
                  new CodeVariableReferenceExpression(optionsVar.Name)
               }
            }
         });

			CodeConditionStatement disposeIf = new CodeConditionStatement {
            Condition = new CodeBinaryOperatorExpression {
               Left = new CodeVariableReferenceExpression(sourceVar.Name),
               Operator = CodeBinaryOperatorType.IdentityInequality,
               Right = new CodePrimitiveExpression(null)
            }
         };
			disposeIf.TrueStatements.Add (new CodeMethodInvokeExpression (
            new CodeMethodReferenceExpression {
               MethodName = "Dispose",
               TargetObject = new CodeVariableReferenceExpression(sourceVar.Name)
            }
			));

			trySt.FinallyStatements.Add (disposeIf);

			statements.AddRange (new CodeStatement[] {
                procVar,
                sourceVar,
                virtualPathVar,
                sourceUriVar,
                trySt
            });
		}
Ejemplo n.º 28
0
        private CodeStatement[] BuildReadStringArrayStatements(MemberType memberType, string classRefName, CodeMemberField memberField)
        {
            CodeStatementCollection statements = new CodeStatementCollection();
            string tempListName = memberField.Name + "_List";

            // Build: string[] tempArray = reader.ReadString().Split();
            CodeVariableDeclarationStatement declaration = new CodeVariableDeclarationStatement(typeof(string[]), tempListName);
            CodeExpression expression = new CodeMethodInvokeExpression(
                new CodeTypeReferenceExpression("reader"),
                "ReadString");
            expression = new CodeMethodInvokeExpression(
                expression,
                "Split");
            declaration.InitExpression = expression;
            statements.Add(declaration);

            if (memberField.Type.ArrayElementType.BaseType == "System.Byte")
            {
                statements.Add(
                    new CodeConditionStatement(
                        new CodeBinaryOperatorExpression(
                            new CodeFieldReferenceExpression(
                                new CodeThisReferenceExpression(),
                                "_CompressByteArrays"
                            ),

                            CodeBinaryOperatorType.BooleanOr,

                            new CodeBinaryOperatorExpression(
                                new CodeBinaryOperatorExpression(
                                    new CodeFieldReferenceExpression(
                                        new CodeVariableReferenceExpression(tempListName),
                                        "Length"),
                                    CodeBinaryOperatorType.ValueEquality,
                                    new CodePrimitiveExpression(1)
                                ),
                                CodeBinaryOperatorType.BooleanAnd,
                                new CodeBinaryOperatorExpression(
                                    new CodeFieldReferenceExpression(
                                        new CodeArrayIndexerExpression(
                                            new CodeVariableReferenceExpression(tempListName),
                                            new CodePrimitiveExpression(0)
                                        ),
                                        "Length"
                                    ),
                                    CodeBinaryOperatorType.GreaterThan,
                                    new CodePrimitiveExpression(2)
                                )
                            )
                        ),
                        BuildBase64ArrayStatement(tempListName, classRefName, memberField),
                        BuildReadStringArrayStatementsNormal(tempListName, classRefName, memberField)
                    )
                );

            }
            else
            {
                statements.AddRange(BuildReadStringArrayStatementsNormal(tempListName, classRefName, memberField));
            }

            // Build a CodeStatement array object to return
            CodeStatement[] codeStatements = new CodeStatement[statements.Count];
            for (int i = 0; i < statements.Count; ++i)
                codeStatements[i] = statements[i];
            return codeStatements;
        }
		public override void AddStatements( CodeStatementCollection collection )
		{
			collection.AddRange( this._statements );
		}
Ejemplo n.º 30
0
 static CodeStatementCollection BuildAttributeGet(AttributeMetadata attribute, CodeTypeReference targetType)
 {
     var statements = new CodeStatementCollection();
     if (((attribute.AttributeType.GetValueOrDefault()) == AttributeTypeCode.PartyList) && (targetType.TypeArguments.Count > 0))
     {
         statements.AddRange(BuildEntityCollectionAttributeGet(attribute.LogicalName, targetType));
         return statements;
     }
     statements.Add(Return(ThisMethodInvoke("GetAttributeValue", targetType, new CodeExpression[] {StringLiteral(attribute.LogicalName)})));
     return statements;
 }