Random photo
Loading...
Domains for sale
|
August 19, 2004Real-world puzzle - Generic syntax for ASP.NETMikhail Arkhipov is trying to come up with any reasonable syntax for expressing generic controls in future versions of ASP.NET (he doesn't think it will be in Whidbey). So far all of them look plain ugly or unextendable (e.g. WRT to multiple types), needless to say malformed according to XML or even SGML: <vc:SomeGenericControl<SomeObjectType> runat="server" /> <vc:SomeGenericControl:SomeObjectType runat="server" /> <vc:SomeGenericControl.SomeObjectType runat="server" /> <vc:SomeGenericControl(SomeObjectType1.SubType1, SomeObjectType2.SubType2) runat="server" />Any ideas? August 19, 2004 11:52 AM
| #.NET
Comments
<ns:Control Type="type1" runat="server" />!! -- and it looks like it is not completely impossible to create generic control classes which can be instantiated this way. at October 2, 2007 12:20 AM
I think trying to mash all the info into the element name with dots, dashes, $ etc is going to get ugly. The <%@Register... option is quite neat. It's like an asp equivalent of a processing instruction. Posted by: Colin at September 8, 2004 1:33 PMUsing $ as delimiter looks interesting too, but unfortunately XML 1.0 doesn't allow $ in XML names (though XML 1.1 does). <%@ Register Tagname="MyControl" TypeName="SomeGenericControl<SomeObjectType>" Assembly="MyAssembly" %> @Register directive isn't XMLish anyway so the syntax can mangled as needed (even including < in attribute value - why not?). Posted by: Oleg Tkachenko at August 20, 2004 8:50 AMMark, you mean something like Sorry guys, I see posting XML in comments stinks. Please replace < with < till I figure out how to make it done automatically. Thanks for your comments! Posted by: Oleg Tkachenko at August 20, 2004 8:00 AMHow about using syntax similar to how C++ mangles generics: <vc:SomeGenericControl$SomeObjectType ... /> Posted by: Sanjay at August 20, 2004 4:58 AM<vc:SomeGenericControl$SomeObjectType.SubType$ runat="server" /> you got the idea Posted by: Anatoly Lubarsky at August 20, 2004 2:50 AMAs a variant on the attribute idea, what about namespaced attributes? Posted by: Mark Bingham at August 20, 2004 12:25 AMWell, moving that information to an attribute seems to be an obvious idea. But as Mikhail pointed out, Why is it necessary to put the parameterized types in the tag? Why not stick them in an attribute? Something like: <vc:SomeGenericControl types="SomeObjectType" runat="server" /> I'm not certain the attribute name is ideal, but you get the idea. Posted by: Steve at August 19, 2004 6:22 PM<ns:Control Type="type1" runat="server" />, of course. Posted by: Samu Lang at August 19, 2004 5:50 PMPost a comment
|