2007-12-18 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Tue, 18 Dec 2007 19:55:51 +0000 (19:55 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Tue, 18 Dec 2007 19:55:51 +0000 (19:55 -0000)
        * CodeDomDesignerLoader.cs: Fix the serialization to use the
        same type as the deserialization.
        * CodeDomSerializer.cs, ComponentCodeDomSerializer.cs:
        Always SetExpression if not set yet.

svn path=/trunk/mcs/; revision=91577

mcs/class/System.Design/System.ComponentModel.Design.Serialization/Changelog
mcs/class/System.Design/System.ComponentModel.Design.Serialization/CodeDomDesignerLoader.cs
mcs/class/System.Design/System.ComponentModel.Design.Serialization/CodeDomSerializer.cs
mcs/class/System.Design/System.ComponentModel.Design.Serialization/ComponentCodeDomSerializer.cs

index 7ab5373b9ea9967bf5165a147e8f111171f3c85c..d59025ba7a4675bb1daeef16d5502f57efd3069a 100644 (file)
@@ -1,3 +1,10 @@
+2007-12-18  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * CodeDomDesignerLoader.cs: Fix the serialization to use the same
+       type as the deserialization.
+       * CodeDomSerializer.cs, ComponentCodeDomSerializer.cs:
+       Always SetExpression if not set yet.
+
 2007-12-18  Ivan N. Zlatev  <contact@i-nz.net>
 
        * ControlCodeDomSerializer.cs: Add. Handles Resume/Suspend
index aafc18afeda1102f6924b0c9fac33f7f40caf4f2..7dec397032b483d8c73e18732921e995ef874929 100644 (file)
@@ -124,7 +124,7 @@ namespace System.ComponentModel.Design.Serialization
 
                        foreach (CodeNamespace namesp in unit.Namespaces) {
                                for (int i=0; i< namesp.Types.Count; i++) {
-                                       if (namesp.Types[i].Name == typeDecl.Name) {
+                                       if (namesp.Types[i].IsClass) {
                                                typeIndex = i;
                                                namespac = namesp;
                                        }
@@ -135,6 +135,7 @@ namespace System.ComponentModel.Design.Serialization
                                namespac.Types.RemoveAt (typeIndex);
 
                        namespac.Types.Add (typeDecl);
+
                        return unit;
                }
 
index 40b03177e2ab36cbd9cd35fcc4223a121c3b7536..46b65d2edea569634f6347cd12491a5d9e08c5c7 100644 (file)
@@ -67,28 +67,23 @@ namespace System.ComponentModel.Design.Serialization
                        if (manager == null)
                                throw new ArgumentNullException ("manager");
 
-                       object serialized = null;
                        bool isComplete = false;
                        CodeExpression createExpr = base.SerializeCreationExpression (manager, value, out isComplete);
-                       if (isComplete) {
-                               serialized = createExpr;
-                               base.SetExpression (manager, value, createExpr);
-                       } else {
+                       if (!isComplete) {
                                ExpressionContext context = manager.Context[typeof (ExpressionContext)] as ExpressionContext;
                                if (context != null && context.PresetValue == value) {
                                        CodeStatementCollection statements = new CodeStatementCollection ();
                                        statements.Add (new CodeAssignStatement (context.Expression, createExpr));
                                        base.SerializeProperties (manager, statements, value, new Attribute[0]);
                                        base.SerializeEvents (manager, statements, value, new Attribute[0]);
-                               } else {
-                                       CodeExpression expression = base.GetExpression (manager, value);
-                                       if (expression == null) {
-                                               serialized = expression = createExpr;
-                                               base.SetExpression (manager, value, expression);
-                                       }
                                }
                        }
-                       return serialized;
+
+                       CodeExpression expression = base.GetExpression (manager, value);
+                       if (expression == null)
+                               base.SetExpression (manager, value, createExpr);
+
+                       return (object)createExpr;
                }
 
         [Obsolete ("This method has been deprecated. Use SerializeToExpression or GetExpression instead.")] 
index 5e2ad80a22e6ccfbb55cdffd3783cc3aa8d1bc34..77f8e7e634e47aa0e61a22bda6b8bfcd93f155e8 100644 (file)
@@ -98,12 +98,13 @@ namespace System.ComponentModel.Design.Serialization
                                serialized = statements;
                        } else {
                                serialized = base.GetExpression (manager, value);
-                               if (serialized == null) {
-                                       base.SetExpression (manager, value, componentRef);
+                               if (serialized == null)
                                        serialized = componentRef;
-                               }
                        }
 
+                       if (base.GetExpression (manager,value) == null)
+                               base.SetExpression (manager, value, componentRef);
+
                        return serialized;
                }
        }