How to create a modul system for a cms? - c#

Im building a CMS (ASP.NET C#) and I am currently looking at how to implement a module system. How is it done with most modularized systems on the web? The most important thing is that I dont want the modules messing with any of the core files.
Example of a case:
I have an ajax search method that is using a webservice method named Search; how can a module "add" its search results to the result list? If the core search only searches webpages and I want the search to also search products in the e-commerce module, how can it add the product search, and its contents, to the original search method's return list? Is that even possible?
Ive been looking at reflection a little bit, and it seems to be useful with running module code from within the core, is that correct?
I have no experience with this kind of stuff, so a push in the right direction, and/or links/guides/tips would be very appreciated.

What you're looking for sounds very much like a plugin-based architecture. I would research some different open source projects and see how they do it, find the one that most similarly resembles what you would like to do, and use their methodology to design your CMS.
One of the largest open source, plugin-based projects is Eclipse, but I would look at some others as well.
You may also do some searches on Google for "component pattern", "module pattern", and "plugin pattern".

I agree with Topher in general.
In the context of ASP.NET and the example you gave, I think the best approach would be for all your modules to implement their own search logic, and expose it through a method. Then the search result would call the method to get the results from all components/modules in the system that implement search.
Generally you should have some kind of framework for the core system and components should be abstracted (interfaces for common functionality). An easy rule of thumb is that "a component gets called, while a framework calls components".
Since the search would be implemented differently depending on the component, it's the job of the component to implement it and the job of the framework to call the implementation.
As an end note, I think you should have an architecture for the whole system before you start thinking about concrete examples, as Topher said.

Related

In orchard where to put my Custom UserRankingActivity code, in a widget or a plugin?

I have some business logic that monitors user activity, badges, audits and ranking. I plan to show the data in a admin and public webpage, so has its own web views.
I am trying to package this into Orchard. While I understand that orchard had modular architecture, but its unclear on what the differences are, or are they the same thing? So, my question is - how should this be packaged this as a widget or a plug-in, or does it not matter?
What would be the different from a) user perspective and b) developer perspective? or are they the same thing?
A module is a bunch of code that relies on Orchard's APIs, (and possibly on the API of other modules), packaged to be easily installed. Widgets are reusable pieces of UI. They are a part of a module, so the question sounds a bit like a category error ;)
Your features have to be packaged in a module, that's the only way to extend Orchard, but what's in that module seems to be the real question here. I'd advise you read more documentation to understand the basic concepts in Orchard, and then it should naturally click into place, and you should be able to figure out what concept to use for each part of your design.
These are good places to start:
http://docs.orchardproject.net/en/latest/Documentation/Basic-Orchard-Concepts/
http://docs.orchardproject.net/en/latest/Documentation/Getting-Started-with-Modules/

Is there a library to provide LDAP-like object structure for C#?

I want to develop a generic Authentication/Authorization library based on Users, Departments, where each department has claims and users could have roles and so on. After so much thinking and searching on web, I think that the most adequate way to go (based on my scenarios) is to develop a LDAP-like structure. This way I could even develop an integration with Active Directory/OpenLDAP after.
Picture taken from here
Before making my own library, i would know: is there a library that already provides objects aiming this structure (this way I could inherit and customize)? I know that we have System.DirectoryServices from .NET Framework and the corresponding library from Mono, but I could not find where the "Entry" classes are. I know that there is a Novell-made library aiming LDAP too, but I think that there is a lot of outdated on the internet about this one.
EDIT
I've found DirectoryEntry class that comes close, but I could not verify if it is Mono compliant.
As you've likely discovered, there are many, many different implementations of the LDAP protocol across a multitude of providers, so finding a one-size-fits-all library is going to be nearly impossible.
However, you're correct is assuming that many of the same concepts (groups, domains, individual entries, etc.) will apply regardless of which provider you're working with, and even the process of connecting to a given directory server, applying a filter based on LDAP syntax, then processing the results that are returned, is extremely common.
Thus, even though said library doesn't exist, you can certainly build an interface around those general concepts from which all of your specific implementations would inherit from.
From a more technical standpoint, you'd be surprised how portable DirectoryEntry is - I use it along with some basic constructs from System.DirectoryServices.Protocols to connect and bind to Active Directory, iPlanet, and OpenDJ, and it works wonderfully.
You also mentioned Novell - for that, I used their .Net library Novell.Directory.Ldap, which you can find here. You'll notice the concept of an "entry" is available here as well, encompassed within the LdapEntry class.

Search engine for .net

I am looking for a search engine that can be used for sites. Sometimes we dont want to use google embedded search or the complication of lucene.
I run in to these requests:
Crawl based search
Rating and ranking of content based on content types
Searching documents like pdf and docs etc..
I dont mind if it is a commercial control that we have to purchase but I would like to be able to integrate it nicely in to some of these use cases
There used to be Lucene.net. Recently the status of this project is becoming questionable (not certain of the details). Here is the site: https://lucenenet.apache.org/
Looks like you can still download the code. Probably not much development going forward.
Bob
I have used dtSearch in the past which I know has a web crawler built into it. It doesn't come with a front end control though, it's strictly a search engine. You need to write your own results control. It does have a powerful query language though that lets you score on multiple dimensions depending on how you set up your indexes. It also has a decent .NET API to work with.
I don't know that this is any less complicated than Lucene though. So then I start to wonder what complications you are hoping to avoid.
You should look at Apache Solr (built using Lucene) - it offers a RESTful interface for integrating into .NET or whatever platform you prefer. It offers all the goodies could ask for without concern for compatibility Java .NET versions etc.
You can easily integrate Solr into your .NET app using SolrNet

Building An App With Plug-in Support

I'm starting a new project which would greatly benefit from program add-ons. The program in its most basic form reads data from a serial port and parses it into database records. Examples of add-ons that could be written would be an auto-archive add-on, an add-on to filter records, etc. I'm writing both the program and the add-ons, but some customers need custom solutions, so instead of branching off and making a completely separate program, add-ons would be great. The simplest add-on would probably be a form who's constructor takes an object reference, manipulates the object in some way, then closes.
Unfortunately, I have absolutely no idea where to start coding, and almost as little idea where to search. Everything I search for turns up browser add-ons. From what I have gathered, I need to look into dynamic loading DLLs. Besides that, I'm clueless. Does anyone have any good resources or examples I that they know of?
I'm happy to provide more details, but this project is in its inception, so I don't have a ton of specific details (specifics kind of defeats the point of add-ons, too.)
You should seriously consider using the Managed Extensibility Framework (MEF) to handle your plugin architecture. It requires thinking about things a little differently, but it is well worth the mind-stretch.
This is a simple example to illustrate the basic technique.
codeproject.com - Plugin Architecture using C#
This article demonstrates to you how
to incorporate ... as a
plugin for another application or use
it as a standalone application.
in .NET 4 you now have the Managed Extensibility Framework (MEF) to do much of the plumbing.
In .NET 3.5 you had the System.AddIn but it was deemed by many to be far too complex.
codeproject.com - AddIn Enabled Applications with System.AddIn
AddIns (sometimes called Plugins) are
seperately compiled components that an
application can locate, load and make
use of at runtime (dynamically). An
application that has been designed to
use AddIns can be enhanced (by
developing more AddIns) without the
need for the orginal application to be
modified or recompiled and tested
You really need to look at Managed Extensibility Framework (MEF). This is specifically designed to help support add-ons and other extensibility.
A very basic description (basically, your plugins must implement a special interface):
http://martinfowler.com/eaaCatalog/plugin.html
Much better article, in C#:
http://www.drdobbs.com/184403942;jsessionid=TVLM2PGYFZZB1QE1GHPCKHWATMY32JVN
I think Reflection will play a major role.
I expirimented with an app that had a plugin folder. A filesystem watcher would watch the folder, and when a new DLL was placed in it, it would use reflection to determine which types of plugins it included, loaded them, and added them to the list of available classes, etc.
Try using the term 'add-in' or 'plug-in' for your research instead of 'add-on'. That should help some.
If you're using .Net 4, there's an add-in namespace in the framework that will get you partway there.
Writing plug-in support for an app is no simple task. You'll have to maintain pretty strict separation-of-concerns across your interfaces, you'll need to provide an interop library that defines ALL of the supported plug-in types, and you'll want to do some research into dependency injection & inversion of control, in addition to the previously-suggested reflection research.
It sounds like you might have a busy weekend doing research.

Creating a reusable cms module (C#)

Are there any resources with information creating a self contained, reusable module?
I need to create modules that I can drop into projects quickly and easily. An example would be a news module that would contain an admin area, news listing page, It supporting CSS & JavaScript, etc.
Am I smoking my socks or is this even possible?
You need plugins for your application.
I've got a plugin library (in development and in Spanish) that you might use as an example or a starting point. I don't know how good google translate will be but you can check a C# plugin tutorial in http://translate.google.com/translate?hl=es&ie=UTF-8&u=http://www.thealphasite.org/es/sistema_de_plugins_con_c_y_net&sl=es&tl=en
A plugin allows you to plug in :P functionality into your application and, with a proper design, it will allow you to move functionality dinamically from one application to another.
Anyway, plugin just provide with ease of use but require a design specifically thought with them in mind. On the other hand, basic "take this module and use it in another project" is just proper encapsulation and good design. If a module is well designed the it should be able to be ported to another site or application with very little effort.
Keep in mind that, specifically for web, "theming" is a complex subject, that is, adapting your plugin to the way an specific web looks is another step of customization which has to be included into the module itself. You can see an example in the Drupal theming functions and the theming api documentation.
Look at www.allnewsmanager.net, maybe is what you are looking for. It is a reusable module, free and open source.
Not sure about any resources - but I've done this myself by writing a CMS from scratch using a combination of user controls for the modules, and a templating system with common code file which loads said user controls into placeholders.
The templating system allows you to create an aspx file, with a bunch of placeholders (as many as you need) - then you need a database or similar to manage what controls go to what placeholders, on what page. A template can handle many pages.
Downloading and studying the architecture for dotnetnuke can enlighten and give ideas for structuring your own approach, even though it's VB, the data structure is just as interesting.

Categories

Resources