private void DumpNodeTree(CodeDomObjectNode rootNode)
        {
            if (rootNode.Type != null)
            {
                Debug.WriteLine(rootNode.Type.Name);
            }

            NodeCollection <MemberNode> members = rootNode.MemberNodes;

            foreach (MemberNode member in members)
            {
                Debug.WriteLine("Member={0}, Type={1}", new object[] { member.Member.Name, member.Member.Type.Name });

                foreach (ItemNode itemNode in member.ItemNodes)
                {
                    ValueNode valueNode = itemNode as ValueNode;

                    if (valueNode != null)
                    {
                        string value = valueNode.Value as String;
                        Debug.WriteLine("Underlying Type={0}, Value={1}", new object[] { member.Member.Type.UnderlyingType, value });
                    }
                    else
                    {
                        CodeDomObjectNode objectNode = (CodeDomObjectNode)itemNode;
                        XamlType          xamlType   = objectNode.Type;

                        if (xamlType == XamlLanguage.Static)
                        {
                            ValueNode valueNode2        = objectNode.XPosParamsNode.ItemNodes[0] as ValueNode;
                            string    xamlTypeReference = valueNode2.Value as string;
                            string    memberName        = null;
                            string    typeName          = null;
                            int       period            = xamlTypeReference.IndexOf('.');
                            if (period > -1)
                            {
                                memberName = xamlTypeReference.Substring(period + 1);
                                typeName   = xamlTypeReference.Substring(0, period);
                            }
                            Type resolvedType = objectNode.Resolve(typeName);
                            //TODO: don't forget to make sure a using happens for the referencedXamlType
                            string typeName2 = resolvedType != null ? resolvedType.Name : xamlTypeReference;

                            Debug.WriteLine("TypeName={0}, MemberName={1}", new object[] { typeName2, memberName });
                        }
                        else if (xamlType == XamlLanguage.Null)
                        {
                            Debug.WriteLine("NULL Expression");
                        }
                        else if (xamlType == XamlLanguage.Type)
                        {
                            ValueNode valueNode2        = objectNode.XPosParamsNode.ItemNodes[0] as ValueNode;
                            string    xamlTypeReference = valueNode2.Value as string;
                            Type      resolvedType      = objectNode.Resolve(xamlTypeReference);
                            //TODO: don't forget to make sure a using happens for the referencedXamlType
                            string typeName = resolvedType != null ? resolvedType.Name : xamlTypeReference;

                            Debug.WriteLine("Type Ref={0}", new object[] { typeName });
                        }
                        else if (xamlType == XamlLanguage.Reference)
                        {
                        }
                        else
                        {
                            if (objectNode.Type != null)
                            {
                                // StartObject case
                                DumpNodeTree(objectNode);
                            }
                            else
                            {
                                // GetObject
                                DumpNodeTree(objectNode);
                            }
                        }
                    }
                }
            }
        }
        private void ProcessItemNode(ItemNode itemNode, CodeMemberMethod initComponentMethod,
                                     MemberNode member, CodeExpression targetExpression)
        {
            CodeDomObjectNode objectNode = (CodeDomObjectNode)itemNode;
            XamlType          xamlType   = objectNode.Type;

            if (xamlType == XamlLanguage.Static)
            {
                //TODO: this could be posParams or named params...
                ValueNode valueNode2        = objectNode.XPosParamsNode.ItemNodes[0] as ValueNode;
                string    xamlTypeReference = valueNode2.Value as string;
                string    memberName        = null;
                string    typeName          = null;
                int       period            = xamlTypeReference.IndexOf('.');
                if (period > -1)
                {
                    memberName = xamlTypeReference.Substring(period + 1);
                    typeName   = xamlTypeReference.Substring(0, period);
                }
                Type resolvedType = objectNode.Resolve(typeName);
                //TODO: don't forget to make sure a using happens for the referencedXamlType
                string typeName2 = resolvedType != null ? resolvedType.Name : xamlTypeReference;
                //CodeTypeReference ctr = new CodeTypeReference(typeName2);
                CodeTypeReferenceExpression     ctre = new CodeTypeReferenceExpression(typeName2);
                CodePropertyReferenceExpression cpre =
                    new CodePropertyReferenceExpression(ctre, memberName);

                GenerateMemberAssignment(initComponentMethod,
                                         member, targetExpression, cpre, objectNode);
            }
            else if (xamlType == XamlLanguage.Null)
            {
                CodePrimitiveExpression nullExpression = new CodePrimitiveExpression(null);
                GenerateMemberAssignment(initComponentMethod,
                                         member, targetExpression, nullExpression, objectNode);
            }
            else if (xamlType == XamlLanguage.Type)
            {
                //TODO: this could be posParams or named params...
                ValueNode valueNode2        = objectNode.XPosParamsNode.ItemNodes[0] as ValueNode;
                string    xamlTypeReference = valueNode2.Value as string;
                Type      resolvedType      = objectNode.Resolve(xamlTypeReference);
                //TODO: don't forget to make sure a using happens for the referencedXamlType
                string               typeName = resolvedType != null ? resolvedType.Name : xamlTypeReference;
                CodeTypeReference    ctr      = new CodeTypeReference(typeName);
                CodeTypeOfExpression typeof1  = new CodeTypeOfExpression(ctr);
                GenerateMemberAssignment(initComponentMethod,
                                         member, targetExpression, typeof1, objectNode);
            }
            else if (xamlType == XamlLanguage.Reference)
            {
            }
            else
            {
                // We have something other than a ValueNode.  Must be a StartObject or GetObject
                initComponentMethod.Statements.Add(new CodeCommentStatement("---------------------------"));
                if (objectNode.Type != null)
                {
                    // Handle special case for Bindings
                    if (objectNode.Type.Name == "Binding")
                    {
                        GenerateBindingObject(initComponentMethod, targetExpression, objectNode, member);
                    }
                    else
                    {
                        // StartObject case
                        GenerateObject(initComponentMethod, targetExpression, objectNode, member);
                    }
                }
                else
                {
                    // GetObject
                    GenerateGetObject(initComponentMethod, targetExpression, objectNode, member);
                }
            }
        }