More changes for XamlObjectWriter unification.
authorAtsushi Eno <atsushi@ximian.com>
Thu, 25 Nov 2010 03:24:06 +0000 (12:24 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Thu, 25 Nov 2010 03:24:06 +0000 (12:24 +0900)
mcs/class/System.Xaml/System.Xaml/XamlWriterStateManager.cs
mcs/class/System.Xaml/System.Xaml/XamlXmlWriter.cs

index 5d147fa06241d4e4564ccf91d7ab728a9d3b9f54..bc034f24fb03fa2ece9dd36392fbe4ac8085e468 100755 (executable)
@@ -108,10 +108,11 @@ namespace System.Xaml
                        allow_object_after_value = isXmlWriter;
                        allow_parallel_values = !isXmlWriter;
                        allow_empty_member = !isXmlWriter;
+                       allow_multiple_results = !isXmlWriter;
                }
 
                // configuration
-               bool allow_ns_at_value, allow_object_after_value, allow_parallel_values, allow_empty_member;
+               bool allow_ns_at_value, allow_object_after_value, allow_parallel_values, allow_empty_member, allow_multiple_results;
 
                // state
                XamlWriteState state = XamlWriteState.Initial;
@@ -146,7 +147,7 @@ namespace System.Xaml
                {
                        RejectNamespaces (XamlNodeType.EndObject);
                        CheckState (XamlNodeType.EndObject);
-                       state = hasMoreNodes ? XamlWriteState.ObjectWritten : XamlWriteState.End;
+                       state = hasMoreNodes ? XamlWriteState.ObjectWritten : allow_multiple_results ? XamlWriteState.Initial : XamlWriteState.End;
                }
 
                public void GetObject ()
index 8c64301ee4582471796d8672eb07e821e658c1fb..cc37df4cb71446d27cd82c12e6cba67c37edd960 100755 (executable)
@@ -196,6 +196,7 @@ namespace System.Xaml
 
                        public string FactoryMethod;
                        public object Value;
+                       public object KeyValue;
                        public List<MemberAndValue> WrittenProperties = new List<MemberAndValue> ();
                        public bool IsInstantiated;
                }
@@ -209,7 +210,6 @@ namespace System.Xaml
 
                        public XamlMember Member;
                        public object Value;
-                       public object KeyValue;
                        public AllowedMemberLocations OccuredAs = AllowedMemberLocations.None;
                }
 
@@ -258,9 +258,6 @@ namespace System.Xaml
 
                        var xm = CurrentMember;
 
-                       if (!xm.Type.IsCollection)
-                               throw new InvalidOperationException (String.Format ("WriteGetObject method can be invoked only when current member '{0}' is of collection type", xm.Name));
-
                        var state = new ObjectState () {Type = xm.Type, IsGetObject = true};
 
                        object_states.Push (state);
@@ -485,9 +482,16 @@ namespace System.Xaml
 
                protected override void OnWriteGetObject ()
                {
-                       WritePendingStartMember (XamlNodeType.GetObject);
+                       if (object_states.Count > 1) {
+                               var state = object_states.Pop ();
 
-                       // Other than above, nothing to do.
+                               if (!CurrentMember.Type.IsCollection)
+                                       throw new InvalidOperationException (String.Format ("WriteGetObject method can be invoked only when current member '{0}' is of collection type", CurrentMember));
+
+                               object_states.Push (state);
+                       }
+
+                       WritePendingStartMember (XamlNodeType.GetObject);
                }
                
                void WritePendingStartMember (XamlNodeType nodeType)