nbsp;save.Name = "save";
save.Attributes = MemberAttributes.Public | MemberAttributes.Final;
System.Collections.Generic.List<CodeStatement> ifStatements =
new System.Collections.Generic.List<CodeStatement>();
//产生 "XmlNode xn = m_xml.CreateNode(XmlNodeType.Element, "item", "");"
CodeVariableDeclarationStatement xmlNode = new CodeVariableDeclarationStatement("System.Xml.XmlNode", "xn");
CodeMethodInvokeExpression createNode = new CodeMethodInvokeExpression(m_XmlExpression, "CreateNode",
new CodeExpression {new CodeVariableReferenceExpression("System.Xml.XmlNodeType.Element"),
new CodePrimitiveExpression("item"),
new CodePrimitiveExpression("") });
xmlNode.InitExpression = createNode;
ifStatements.Add(xmlNode);
//产生 "XmlAttribute xa = null; "
CodeVariableDeclarationStatement xmlAttr = new CodeVariableDeclarationStatement("System.Xml.XmlAttribute", "xa");
xmlAttr.InitExpression = new CodePrimitiveExpression(null);
ifStatements.Add(xmlAttr);
//产生字段属性
CodeStatementCollection statements = new CodeStatementCollection();
foreach (XmlNode xn in m_Xml.DocumentElement.ChildNodes)
{
CodeMethodInvokeExpression createAttribute = new CodeMethodInvokeExpression(m_XmlExpression,
"CreateAttribute", new CodePrimitiveExpression(xn.Name));
CodeAssignStatement assignxa = new CodeAssignStatement(
new CodeVariableReferenceExpression("xa"), createAttribute);
CodeMethodInvokeExpression invokeToString = new CodeMethodInvokeExpression(
new CodeVariableReferenceExpression("m_" + xn.Name), "ToString");
CodeAssignStatement assignValue = new CodeAssignStatement(
new CodeVariableReferenceExpression("xa.Value"), invokeToString);
CodeMethodInvokeExpression invokeAppend = new CodeMethodInvokeExpression(
new CodeVariableRefe