/// <summary> /// Creates a ParsingObject as a child of this one, and returns it. /// </summary> public virtual ParsingObject CreateChildParsingObject(ILocation location, string tagid, TagAttributes attributes) { string[] str = tagid.Split(':'); //html tags //TODO: check for valid tags? if (str.Length == 1) { if (attributes.IsRunAtServer() && (0 == string.Compare("form", tagid))) { return(new ServerFormParsingObject(location.PlainText, tagid, this)); } return(new HtmlParsingObject(location.PlainText, tagid, this)); } //fall through to server tags if (str.Length != 2) { throw new ParseException(location, "Server tag name is not of form prefix:name"); } Type tagType = WebFormReferenceManager.GetObjectType(str[0], str[1]); if (tagType == null) { throw new ParseException(location, "The tag " + tagid + "has not been registered"); } return(new ServerObjectParsingObject(tagType, attributes.GetDictionary(null), tagid, this)); }
public EditorHost (MonoDevelopProxy proxy) { this.proxy = proxy; //set up the services services = new ServiceContainer (); services.AddService (typeof(INameCreationService), new NameCreationService ()); services.AddService (typeof(ISelectionService), new SelectionService ()); services.AddService (typeof(ITypeResolutionService), new TypeResolutionService ()); services.AddService ( typeof(IEventBindingService), new AspNetEdit.Editor.ComponentModel.EventBindingService (proxy) ); ExtenderListService extListServ = new ExtenderListService (); services.AddService (typeof(IExtenderListService), extListServ); services.AddService (typeof(IExtenderProviderService), extListServ); services.AddService (typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService ()); services.AddService (typeof (IMenuCommandService), new AspNetEdit.Editor.ComponentModel.MenuCommandService ()); //services.AddService (typeof (IToolboxService), toolboxService); var project = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.Project as AspNetAppProject; var aspParsedDoc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as AspNetParsedDocument; if (project != null && aspParsedDoc != null) { WebFormReferenceManager refMan = new WebFormReferenceManager (project); refMan.Doc = aspParsedDoc; services.AddService (typeof(WebFormReferenceManager), refMan); } System.Diagnostics.Trace.WriteLine ("Creating DesignerHost"); designerHost = new DesignerHost (services, this); System.Diagnostics.Trace.WriteLine ("Created DesignerHost"); designerHost.DocumentChanged += new DesignerHost.DocumentChangedEventHandler (OnDocumentChanged); }
private void handleToolboxNode(ItemToolboxNode node) { ToolboxItemToolboxNode tiNode = node as ToolboxItemToolboxNode; if (tiNode != null) { //load the type into this process and get the ToolboxItem tiNode.Type.Load(); System.Drawing.Design.ToolboxItem ti = tiNode.GetToolboxItem(); //web controls have sample HTML that need to be deserialised, in a ToolboxDataAttribute //TODO: Fix WebControlToolboxItem and (mono classlib's use of it) so we don't have to mess around with type lookups and attributes here if (ti.AssemblyName != null && ti.TypeName != null) { //look up and register the type ITypeResolutionService typeRes = (ITypeResolutionService)designerHost.GetService(typeof(ITypeResolutionService)); typeRes.ReferenceAssembly(ti.AssemblyName); Type controlType = typeRes.GetType(ti.TypeName, true); //read the WebControlToolboxItem data from the attribute AttributeCollection atts = TypeDescriptor.GetAttributes(controlType); System.Web.UI.ToolboxDataAttribute tda = (System.Web.UI.ToolboxDataAttribute)atts [typeof(System.Web.UI.ToolboxDataAttribute)]; //if it's present if (tda != null && tda.Data.Length > 0) { //look up the tag's prefix and insert it into the data WebFormReferenceManager webRef = designerHost.GetService(typeof(WebFormReferenceManager)) as WebFormReferenceManager; if (webRef == null) { throw new Exception("Host does not provide an IWebFormReferenceManager"); } string aspText = String.Format(tda.Data, webRef.GetTagPrefix(controlType)); System.Diagnostics.Trace.WriteLine("Toolbox processing ASP.NET item data: " + aspText); //and add it to the document designerHost.RootDocument.InsertFragment(aspText); return; } } //No ToolboxDataAttribute? Get the ToolboxItem to create the components itself ti.CreateComponents(designerHost); } }
public override ParsingObject CreateChildParsingObject(ILocation location, string tagid, TagAttributes attributes) { switch (mode) { case ParseChildrenMode.DefaultProperty: //oops, we didn't need to tokenise this. innerText += location.PlainText; //how do we get end tag? throw new NotImplementedException("Inner default properties that look like tags have not been implemented yet."); case ParseChildrenMode.DefaultEncodedProperty: innerText += System.Web.HttpUtility.HtmlDecode(location.PlainText); //how do we get end tag? throw new NotImplementedException("Inner default properties that look like tags have not been implemented yet."); case ParseChildrenMode.Controls: //html tags if (tagid.IndexOf(':') == -1) { return(new HtmlParsingObject(location.PlainText, tagid, this)); } goto case ParseChildrenMode.DefaultCollectionProperty; case ParseChildrenMode.DefaultCollectionProperty: string[] str = tagid.Split(':'); if (str.Length != 2) { throw new ParseException(location, "Server tag name is not of form prefix:name"); } Type tagType = WebFormReferenceManager.GetObjectType(str[0], str[1]); if (tagType == null) { throw new ParseException(location, "The tag " + tagid + "has not been registered"); } return(new ServerObjectParsingObject(tagType, attributes.GetDictionary(null), tagid, this)); case ParseChildrenMode.Properties: throw new NotImplementedException("Multiple child properties have not yet been implemented."); } throw new ParseException(location, "Unexpected state encountered: "); }
public EditorHost(MonoDevelopProxy proxy) { this.proxy = proxy; //set up the services services = new ServiceContainer(); services.AddService(typeof(INameCreationService), new NameCreationService()); services.AddService(typeof(ISelectionService), new SelectionService()); services.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); services.AddService( typeof(IEventBindingService), new AspNetEdit.Editor.ComponentModel.EventBindingService(proxy) ); ExtenderListService extListServ = new ExtenderListService(); services.AddService(typeof(IExtenderListService), extListServ); services.AddService(typeof(IExtenderProviderService), extListServ); services.AddService(typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService()); services.AddService(typeof(IMenuCommandService), new AspNetEdit.Editor.ComponentModel.MenuCommandService()); //services.AddService (typeof (IToolboxService), toolboxService); var project = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.Project as AspNetAppProject; var aspParsedDoc = MonoDevelop.Ide.IdeApp.Workbench.ActiveDocument.ParsedDocument as AspNetParsedDocument; if (project != null && aspParsedDoc != null) { WebFormReferenceManager refMan = new WebFormReferenceManager(project); refMan.Doc = aspParsedDoc; services.AddService(typeof(WebFormReferenceManager), refMan); } System.Diagnostics.Trace.WriteLine("Creating DesignerHost"); designerHost = new DesignerHost(services, this); System.Diagnostics.Trace.WriteLine("Created DesignerHost"); designerHost.DocumentChanged += new DesignerHost.DocumentChangedEventHandler(OnDocumentChanged); }