Page 1 of 1

overriding System.Web.HttpApplication.Init?

PostPosted: Thu May 21, 2009 6:46 am
by gauthier
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?

Re: overriding System.Web.HttpApplication.Init?

PostPosted: Thu May 21, 2009 10:20 am
by Charles
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.

Re: overriding System.Web.HttpApplication.Init?

PostPosted: Thu May 21, 2009 10:44 am
by gauthier
Thanks for the hint, it's helpfull

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

Re: overriding System.Web.HttpApplication.Init?

PostPosted: Thu May 21, 2009 7:16 pm
by Charles
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.

Re: overriding System.Web.HttpApplication.Init?

PostPosted: Thu May 21, 2009 9:45 pm
by Charles
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.