Part of fix #3003 - use On[Before|After]Properties event on XamlObjectWriterSettings.
authorAtsushi Eno <atsushi@ximian.com>
Fri, 9 Mar 2012 08:51:35 +0000 (17:51 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Fri, 9 Mar 2012 08:51:35 +0000 (17:51 +0900)
mcs/class/System.Xaml/System.Xaml/XamlObjectWriter.cs
mcs/class/System.Xaml/System.Xaml/XamlWriterInternalBase.cs

index 76f67bc6f6a3ca4507785602e22ba81f5226ffaf..9c5747c557fe981b64ef17ebb751985ae68e94e3 100644 (file)
@@ -250,7 +250,8 @@ namespace System.Xaml
                        if (!state.Type.IsContentValue (service_provider))
                                InitializeObjectIfRequired (true);
 
-
+                       state.IsXamlWriterCreated = true;
+                       source.OnBeforeProperties (state.Value);
                }
 
                protected override void OnWriteGetObject ()
@@ -281,6 +282,11 @@ namespace System.Xaml
                                        throw new XamlObjectWriterException ("An error occured on getting provided value", ex);
                                }
                        }
+                       
+                       // call this (possibly) before the object is added to parent collection. (bug #3003 also expects this)
+                       if (state.IsXamlWriterCreated)
+                               source.OnAfterProperties (obj);
+                       
                        var nfr = obj as NameFixupRequired;
                        if (nfr != null && object_states.Count > 0) { // IF the root object to be written is x:Reference, then the Result property will become the NameFixupRequired. That's what .NET also does.
                                // actually .NET seems to seek "parent" object in its own IXamlNameResolver implementation.
index d22845feeef26f42324d2dc95d70fb6633478223..0dad3a2fc9387b07d08c35054849ca1ada83af63 100644 (file)
@@ -1,5 +1,6 @@
 //
 // Copyright (C) 2010 Novell Inc. http://novell.com
+// Copyright (C) 2012 Xamarin Inc. http://xamarin.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -80,6 +81,7 @@ namespace System.Xaml
                        public object KeyValue;
                        public List<MemberAndValue> WrittenProperties = new List<MemberAndValue> ();
                        public bool IsInstantiated;
+                       public bool IsXamlWriterCreated; // affects AfterProperties() calls.
                }
                
                internal class MemberAndValue