mojoPortal & partial classes

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
11/26/2006 1:42:01 AM
Gravatar
Total Posts 10

mojoPortal & partial classes

When developing your own modules and other stuff you often have to modify existing mojoPortal code (like dPortal.cs file). But I think that the base framework code should be intact when you want to develop your own module.

One solution would be to write all necessary classes like dbPortalYourModule.cs which extends the base dbPortal class. In many cases that would be sufficient. But sometimes it may not work because you need the dbPortal instance (and not dbPortalYourModule instance, although it extends the base dbPortal class). Therefore I think it would be a good idea to mark the dbPortal (and why not other such kind of classes) to be partial classes. Then it's easy to write your partial class and put all module specific functionality to there.

What you think of it? Maybe you have some better ideas already?
11/26/2006 2:02:08 AM
Gravatar
Total Posts 18439

Re: mojoPortal & partial classes

Hi,

Partial classes would be useful if you did want to compile your custom methods into dbPortal, but it is not what I recommend, it is better not to mingle your custom code with the core code.

dbYourFeature is the correct solution. It does not need to and should not extend or have anything to do with dbPortal. Ideally you would write multiple versions of dbYourFeature to support the multiple databases if you were planning to sell or share your custom feature but this is not needed to use it yourself.
You would only need to reference the ADO.NET driver layer, like for MySQL your dbFeatureName would reference MySql.Data, for MS SQL the driver is built into the.NET framework (System.Data.SqlClient) but you might want to copy the SqlHelper class from the mojoportal data layer as this helper class simplifies the code you write quite a bit.
The MySQL Connector has a similar MySqlHelper included with it. For PostgreSQL you might want to borrow the pgsqlHelper class, it may later become part of the npgsql project and be included.

You can write complete features that are entirely in separate assemblies and plug into mojoportal without modifying mojoportal code. Your web ui would need to reference mojoPortal.Web and the Module control which is the entry point of your feature would need to inherit from SiteModuleControl. If you look in the VS Solution there is a SampleExternalModule project that illustrates this. The main trick is a post build action that copies the needed files into the appropriate places beneath the Web folder. If you right click the project node in VS solution explorer and got to properties you can find the post build actions.

I will be writing a tutorial on implementing custom features as external projects very soon.

Best Regards,

Joe
11/26/2006 2:09:46 AM
Gravatar
Total Posts 10

Re: mojoPortal & partial classes

Okey. You have a point.
Thanks for the explanation about SampleExternalModule project :)
11/26/2006 5:53:12 AM
Gravatar
Total Posts 10

Re: mojoPortal & partial classes

Does this xcopy method works with ASP.NET specific directories too? Like App_GlobalResources ?
11/26/2006 6:07:16 AM
Gravatar
Total Posts 18439

Re: mojoPortal & partial classes

I would think so. You would just need to make sure you name your resource files different than the ones already in mojoPortal Web so as not to overwrite them.
Like in mojoPortal Web we have Resource.resx and Resource.x.resx where x is a culture, you would want to name your differently like
MyFeatureResource.resx
MyFeatureResource.x.resx

I haven't tested this yet but thats my theory :-)

I am getting ready to start working with a major project this way so I will soon find out and this will give us a more substantial example of an external module than the current SampleExternalModule which is rather a trivial example.

Joe
You must sign in to post in the forums. This thread is closed to new posts.