This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

* Made <br>, <hr> effectively self-closing to stop page parser getting

confused
* Fixed dropdown selection of null control in propertygrid
* Fixed bound event deserialisation in page parser

svn path=/trunk/aspeditor/; revision=49927
  • Loading branch information...
mhutch committed Sep 11, 2005
1 parent 2679124 commit ed28d93881a7f2104b769a219b395adff9f0fb31
@@ -81,7 +81,7 @@ public IComponent CreateComponent (Type componentClass, string name)
if (componentClass == null)
throw new ArgumentNullException ("componentClass");
if (!componentClass.IsSubclassOf (typeof (System.Web.UI.Control)) && componentClass != typeof (System.Web.UI.Control))
- throw new ArgumentException ("componentClass must be a subclass of System.Web.UI.Control", "componentClass");
+ throw new ArgumentException ("componentClass must be a subclass of System.Web.UI.Control, but is a " + componentClass.ToString (), "componentClass");
if (componentClass.IsSubclassOf (typeof (System.Web.UI.Page)))
throw new InvalidOperationException ("You cannot directly add a page to the host. Use NewFile() instead");
@@ -92,9 +92,10 @@ public IComponent CreateComponent (Type componentClass, string name)
//and add to container
container.Add (component, name);
- //add to document
- ((Control)RootComponent).Controls.Add ((Control) component);
- RootDocument.AddControl ((Control)component);
+ //add to document, unless loading
+ ((Control)RootComponent).Controls.Add ((Control) component);
+ if (RootDocument != null)
+ RootDocument.AddControl ((Control)component);
//select it
ISelectionService sel = this.GetService (typeof (ISelectionService)) as ISelectionService;
@@ -33,6 +33,7 @@
using System.ComponentModel;
using System.Collections;
using System.Reflection;
+using System.Globalization;
namespace AspNetEdit.Editor.ComponentModel
{
@@ -160,6 +161,7 @@ private ParameterInfo[] GetEventParameters (EventDescriptor e)
internal class EventPropertyDescriptor : PropertyDescriptor
{
private EventDescriptor eDesc;
+ private TypeConverter tc;
public EventPropertyDescriptor (EventDescriptor eDesc)
: base (eDesc)
@@ -210,7 +212,7 @@ public override bool ShouldSerializeValue (object component)
return true;
}
- IDictionaryService GetDictionaryService (object component)
+ internal static IDictionaryService GetDictionaryService (object component)
{
if (component == null)
throw new ArgumentNullException ("component");
@@ -225,8 +227,16 @@ IDictionaryService GetDictionaryService (object component)
return dict;
}
+ public override TypeConverter Converter {
+ get {
+ if (tc == null)
+ tc = TypeDescriptor.GetConverter (string.Empty);
+ return tc;
+ }
+ }
+
internal EventDescriptor InternalEventDescriptor {
get { return eDesc; }
}
- }
+ }
}
@@ -132,7 +132,12 @@ void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes
case TagType.ServerComment:
throw new NotImplementedException ("Server comments have not yet been implemented: " + location.PlainText);
break;
- case TagType.Tag:
+ case TagType.Tag:
+ //TODO: don't do this for XHTML
+ if ((string.Compare (tagid, "br", true) == 0)
+ || (string.Compare (tagid, "hr", true) == 0))
+ goto case TagType.SelfClosing;
+
openObject = openObject.CreateChildParsingObject(location, tagid, attributes);
break;
case TagType.SelfClosing:
@@ -51,13 +51,18 @@ internal class ServerObjectParsingObject : ParsingObject
public ServerObjectParsingObject(Type type, Hashtable attributes, string tagid, ParsingObject parent)
: base (tagid, parent)
{
- //create the object
- obj = Activator.CreateInstance (type);
+ //create the object
+ if (type.GetInterface ("System.ComponentModel.IComponent") != null)
+ obj = base.DesignerHost.CreateComponent (type, attributes["ID"] as string);
+ else
+ obj = Activator.CreateInstance (type);
//and populate it from the attributes
pdc = TypeDescriptor.GetProperties (obj);
foreach (DictionaryEntry de in attributes) {
if (0 == string.Compare((string)de.Key, "runat"))
+ continue;
+ if (0 == string.Compare((string)de.Key, "ID"))
continue;
//use the dash subproperty syntax
string[] str = ((string)de.Key).Split ('-');
@@ -83,7 +88,7 @@ public ServerObjectParsingObject(Type type, Hashtable attributes, string tagid,
{
if (pd == null)
throw new Exception ("Could not find property " + (string)de.Key);
-
+ Console.WriteLine (pd.Converter.ToString() + " " + pd.Name);
if (i == str.Length - 1) {
pd.SetValue (obj, pd.Converter.ConvertFromString ((string) de.Value));
break;
@@ -189,7 +194,7 @@ public override ParsingObject CloseObject (string closingTagText)
//FIME: what if it isn't?
if (obj is Control)
base.AddText ( Document.RenderDesignerControl ((Control)obj));
- base.AddControl (obj);
+ //base.AddControl (obj);
return base.CloseObject (closingTagText);
}
@@ -67,7 +67,7 @@ public PropertyGrid (ServiceContainer parentServices)
this.PackStart (combo, false, false, 3);
- //for selecting nothing
+ //for selecting nothing, i.e. deselect all
components.AppendValues (new object[] { "", null} );
combo.Changed += new EventHandler (combo_Changed);
@@ -83,7 +83,7 @@ void combo_Changed (object sender, EventArgs e)
IComponent comp = (IComponent) components.GetValue(t, 1);
//Tell everybody about the new selection. We'll hear about this too.
- selectionService.SetSelectedComponents (new IComponent[] { comp });
+ selectionService.SetSelectedComponents ((comp == null)? null : new IComponent[] { comp });
}
// We need these services to be present, but we cache references for efficiency

0 comments on commit ed28d93

Please sign in to comment.