[Monodevelop-patches-list] r2320 - trunk/MonoDevelop/Unused/Gdl
John Luke <jluke@cfl.rr.com>
jluke at mono-cvs.ximian.com
Tue Mar 8 23:01:54 EST 2005
Author: jluke
Date: 2005-03-08 23:01:53 -0500 (Tue, 08 Mar 2005)
New Revision: 2320
Added:
trunk/MonoDevelop/Unused/Gdl/AfterAttribute.cs
trunk/MonoDevelop/Unused/Gdl/ExportAttribute.cs
Removed:
trunk/MonoDevelop/Unused/Gdl/ExportLayoutAttribute.cs
Modified:
trunk/MonoDevelop/Unused/Gdl/Dock.cs
trunk/MonoDevelop/Unused/Gdl/DockItem.cs
trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs
trunk/MonoDevelop/Unused/Gdl/DockObject.cs
trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
trunk/MonoDevelop/Unused/Gdl/DockPlaceholder.cs
trunk/MonoDevelop/Unused/Gdl/Makefile
trunk/MonoDevelop/Unused/Gdl/TODO
Log:
redo de-serialization better using attributes
Added: trunk/MonoDevelop/Unused/Gdl/AfterAttribute.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/AfterAttribute.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/AfterAttribute.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -0,0 +1,10 @@
+using System;
+
+namespace Gdl
+{
+ [AttributeUsage (AttributeTargets.Property)]
+ public sealed class AfterAttribute : Attribute
+ {
+ }
+}
+
Modified: trunk/MonoDevelop/Unused/Gdl/Dock.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/Dock.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/Dock.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -86,7 +86,7 @@
DockObjectFlags |= DockObjectFlags.Attached;
}
- [ExportLayout]
+ [Export]
public bool Floating {
get {
return floating;
@@ -96,7 +96,7 @@
}
}
- [ExportLayout]
+ [Export]
public int FloatX {
get {
return floatX;
@@ -108,7 +108,7 @@
}
}
- [ExportLayout]
+ [Export]
public int FloatY {
get {
return floatY;
@@ -120,7 +120,7 @@
}
}
- [ExportLayout]
+ [Export]
public int Height {
get {
return height;
@@ -164,7 +164,7 @@
}
}
- [ExportLayout]
+ [Export]
public int Width {
get { return width; }
set {
@@ -174,21 +174,6 @@
}
}
- // <dock name="__dock_1" floating="no" width="-1" height="-1" floatx="0" floaty="0">
- public override void FromXml (XmlNode node)
- {
- string floating = node.Attributes["floating"].Value;
- this.Floating = floating == "no" ? false : true;
- string width = node.Attributes["width"].Value;
- this.Width = int.Parse (width);
- string height = node.Attributes["height"].Value;
- this.Height = int.Parse (height);
- string floatx = node.Attributes["floatx"].Value;
- this.FloatX = int.Parse (floatx);
- string floaty = node.Attributes["floaty"].Value;
- this.FloatY = int.Parse (floaty);
- }
-
protected override void OnSizeRequested (ref Requisition requisition)
{
requisition.Width = 2 * (int)BorderWidth;
Modified: trunk/MonoDevelop/Unused/Gdl/DockItem.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockItem.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/DockItem.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -176,7 +176,7 @@
}
}
- [ExportLayout]
+ [Export]
public bool Locked {
get {
return ((behavior & DockItemBehavior.Locked) != 0);
@@ -196,7 +196,7 @@
}
}
- [ExportLayout]
+ [Export]
public Orientation Orientation {
get {
return orientation;
@@ -309,15 +309,6 @@
invoker.Invoke (Child);
}
- // <item name="Item1" orientation="vertical" locked="no"/>
- public override void FromXml (XmlNode node)
- {
- string orientation = node.Attributes["orientation"].Value;
- this.Orientation = orientation == "vertical" ? Orientation.Vertical : Orientation.Horizontal;
- string locked = node.Attributes["locked"].Value;
- this.Locked = locked == "no" ? false : true;
- }
-
protected override void OnSizeRequested (ref Requisition requisition)
{
requisition.Width = ((int)BorderWidth + Style.XThickness) * 2;
Modified: trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/DockNotebook.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -93,19 +93,6 @@
Dock ((DockObject)w, dockInfo.position, dockInfo.data);
}
- public override void FromXml (XmlNode node)
- {
- string orientation = node.Attributes["orientation"].Value;
- this.Orientation = orientation == "vertical" ? Orientation.Vertical : Orientation.Horizontal;
- string locked = node.Attributes["locked"].Value;
- this.Locked = locked == "no" ? false : true;
- }
-
- public override void FromXmlAfter (XmlNode node)
- {
- this.Page = int.Parse (node.Attributes["page"].Value);
- }
-
public override void OnDocked (DockObject requestor, DockPlacement position, object data)
{
/* we only add support for DockPlacement.Center docking
@@ -197,7 +184,8 @@
get { return true; }
}
- [ExportLayout]
+ [After]
+ [Export]
public int Page {
get { return ((Notebook)Child).CurrentPage; }
set { ((Notebook)Child).CurrentPage = value; }
Modified: trunk/MonoDevelop/Unused/Gdl/DockObject.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockObject.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/DockObject.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -18,6 +18,8 @@
private string longName;
private string stockid;
private bool reducePending;
+
+ private PropertyInfo[] publicProps;
public event DetachedHandler Detached;
public event DockedHandler Docked;
@@ -101,7 +103,7 @@
}
}
- [ExportLayout]
+ [Export]
public new string Name {
get {
return name;
@@ -132,14 +134,55 @@
}
}
- public virtual void FromXml (XmlNode node)
+ private PropertyInfo[] PublicProps {
+ get {
+ if (publicProps == null)
+ publicProps = this.GetType ().GetProperties (BindingFlags.Public | BindingFlags.Instance);
+ return publicProps;
+ }
+ }
+
+ void SetPropertyValue (string property, string val, bool after)
{
+ foreach (PropertyInfo p in PublicProps) {
+ if (after) {
+ if (p.IsDefined (typeof (AfterAttribute), true))
+ SetPropertyValue (p, property, val);
+ }
+ else {
+ if (!p.IsDefined (typeof (AfterAttribute), true))
+ SetPropertyValue (p, property, val);
+ }
+ }
}
- public virtual void FromXmlAfter (XmlNode node)
+ void SetPropertyValue (PropertyInfo pi, string property, string val)
{
+ if (property != pi.Name.ToLower ())
+ return;
+
+ if (pi.PropertyType.IsSubclassOf (typeof (System.Enum)))
+ pi.SetValue (this, Enum.Parse (pi.PropertyType, val, true), null);
+ else if (pi.PropertyType == typeof (bool))
+ pi.SetValue (this, val == "no" ? false : true, null);
+ else if (pi.PropertyType == typeof (int))
+ pi.SetValue (this, int.Parse (val), null);
+ else
+ pi.SetValue (this, val, null);
}
+ public void FromXml (XmlNode node)
+ {
+ foreach (XmlAttribute att in node.Attributes)
+ SetPropertyValue (att.Name, att.Value, false);
+ }
+
+ public void FromXmlAfter (XmlNode node)
+ {
+ foreach (XmlAttribute att in node.Attributes)
+ SetPropertyValue (att.Name, att.Value, true);
+ }
+
string GetXmlName (Type t)
{
switch (t.ToString ()) {
@@ -163,9 +206,8 @@
// get object exported attributes
ArrayList exported = new ArrayList ();
- PropertyInfo[] props = t.GetProperties (BindingFlags.Public | BindingFlags.Instance);
- foreach (PropertyInfo p in props) {
- if (p.IsDefined (typeof (ExportLayoutAttribute), true))
+ foreach (PropertyInfo p in PublicProps) {
+ if (p.IsDefined (typeof (ExportAttribute), true))
exported.Add (p);
}
Modified: trunk/MonoDevelop/Unused/Gdl/DockPaned.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockPaned.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/DockPaned.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -33,7 +33,8 @@
}
}
- [ExportLayout]
+ [After]
+ [Export]
public int Position {
get {
if (Child != null && Child is Paned) {
@@ -67,22 +68,6 @@
Child.Show ();
}
- // <paned orientation="horizontal" locked="no" position="226">
- public override void FromXml (XmlNode node)
- {
- string orientation = node.Attributes["orientation"].Value;
- this.Orientation = orientation == "horizontal" ? Orientation.Horizontal : Orientation.Vertical;
- CreateChild (this.Orientation);
- string locked = node.Attributes["locked"].Value;
- this.Locked = locked == "no" ? false : true;
- }
-
- public override void FromXmlAfter (XmlNode node)
- {
- // FIXME: still dont work
- this.Position = int.Parse (node.Attributes["position"].Value);
- }
-
protected override void OnAdded (Widget widget)
{
if (Child == null)
Modified: trunk/MonoDevelop/Unused/Gdl/DockPlaceholder.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/DockPlaceholder.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/DockPlaceholder.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -53,7 +53,8 @@
}
}
- [ExportLayout]
+ [After]
+ [Export]
public DockPlacement NextPlacement {
get {
if (placementStack != null && placementStack.Count != 0)
@@ -77,12 +78,6 @@
}
}
- public override void FromXmlAfter (XmlNode node)
- {
- throw new NotImplementedException ();
- // NextPlacement
- }
-
protected override void OnDestroyed ()
{
if (host != null)
Added: trunk/MonoDevelop/Unused/Gdl/ExportAttribute.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/ExportAttribute.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/ExportAttribute.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -0,0 +1,10 @@
+using System;
+
+namespace Gdl
+{
+ [AttributeUsage (AttributeTargets.Property)]
+ public sealed class ExportAttribute : Attribute
+ {
+ }
+}
+
Deleted: trunk/MonoDevelop/Unused/Gdl/ExportLayoutAttribute.cs
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/ExportLayoutAttribute.cs 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/ExportLayoutAttribute.cs 2005-03-09 04:01:53 UTC (rev 2320)
@@ -1,9 +0,0 @@
-using System;
-
-namespace Gdl
-{
- public sealed class ExportLayoutAttribute : Attribute
- {
- }
-}
-
Modified: trunk/MonoDevelop/Unused/Gdl/Makefile
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/Makefile 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/Makefile 2005-03-09 04:01:53 UTC (rev 2320)
@@ -30,7 +30,8 @@
Dock.cs \
DockPaned.cs \
DockItemBehavior.cs \
- ExportLayoutAttribute.cs
+ ExportAttribute.cs \
+ AfterAttribute.cs
all: $(GDL) $(TEST)
Modified: trunk/MonoDevelop/Unused/Gdl/TODO
===================================================================
--- trunk/MonoDevelop/Unused/Gdl/TODO 2005-03-09 03:16:41 UTC (rev 2319)
+++ trunk/MonoDevelop/Unused/Gdl/TODO 2005-03-09 04:01:53 UTC (rev 2320)
@@ -1,5 +1,4 @@
- proper license headers
- - improve de-serialization (also use ExportLayoutAttribute?)
- fix notebook.Position after
- placeholders in layout store/restore
- docs
More information about the Monodevelop-patches-list
mailing list