Forums

overriding System.Web.HttpApplication.Init?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

overriding System.Web.HttpApplication.Init?

Postby gauthier » Thu May 21, 2009 6:46 am

I've a problem overriding this member:

namespace smoothdev.Web.Sample.MonoRail
use System.Web

class Application
inherits HttpApplication

def init is override
pass


which give
Code: Select all
error: The modifier "override" is not valid for this item (C#)

the csharp output is trying to redefine a default constructor for the class

any idea how to workaround?
gauthier
 
Posts: 116

Re: overriding System.Web.HttpApplication.Init?

Postby Charles » Thu May 21, 2009 10:20 am

The best that comes to mind is that you could make the class partial:
class Foo inherits Bar is partial
and then have an additional C# file that you pass to Cobra that you use to override the Init() virtual method. You can pass .cs files directly to cobra.exe and it will include them in the final compilation:
Code: Select all
cobra Foo.cobra FooInit.cs

If you have a lot of code to put in there, you could call back to Cobra in with "PrivateInit();" in the .cs file and have a "def privateInit" in the Cobra file.

I'll see if I can get this fixed soon.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: overriding System.Web.HttpApplication.Init?

Postby gauthier » Thu May 21, 2009 10:44 am

Thanks for the hint, it's helpfull

maybe now cue init should be the only way to declare class constructor for disambiguation?
gauthier
 
Posts: 116

Re: overriding System.Web.HttpApplication.Init?

Postby Charles » Thu May 21, 2009 7:16 pm

Yep. Working on it now and changing initializers nodes to have the internal name "cue.init" rather than "init" which will avoid conflicts.

Thanks for the report.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: overriding System.Web.HttpApplication.Init?

Postby Charles » Thu May 21, 2009 9:45 pm

Fixed in the repository. I used your example as the new test case.

"cue init" is still for initializers and "def init" is now for methods. I also made some internal improvements to the code which should help avoid future conflicts.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 74 guests