This project is read-only.

Overriding Orchard.Framework interfaces from a module?

Topics: Customizing Orchard, Writing modules
Apr 23, 2011 at 2:32 PM

Hello All,

I'm looking into creating a new implementation of the Orchard.UI.Resources.ResourceManager in the Orchard.Framework project.  My goals are to:

  1. Integrate Telerik's Web Asset Manager logic at the framework level so that we can get JavaScript and CSS combination, compression and caching with no change to existing themes.
  2. Learn more about dependency injection from modules in the Orchard framework.

I've looked through the Orchard source, and haven't stumbled across a module trying to override an Orchard.Framework interface, so I thought I'd ask here just to make sure that it's possible and I'm going about it in the correct way.

I've created a new module using the codegen tools and created a single file in a folder called "Resources":

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Autofac.Features.Metadata;
using Orchard.Environment.Extensions.Models;
using Orchard.UI.Resources;
using Orchard;
using JetBrains.Annotations;

namespace Slamm.Orchard.WebAssetManager.Resources {
    public class ResourceManager : global::Orchard.UI.Resources.ResourceManager, IResourceManager

        public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders)
            : base(resourceProviders)

        public override IList<String> GetRegisteredFootScripts() {
            return base.GetRegisteredFootScripts();



After enabling this module, I'm unable to get the debugger to break in either the constructor or the GetRegisteredFootScripts method I'm overriding above.  Hence I'm guessing that it's not being injected by Autofac. 

  1. I've seen recommendations to be sure to add a module dependency on the module you're trying to override, but I don't think Orchard.Framework is exposed that way?  Not sure if I'm missing something here.
  2. As I'm trying to avoid modifying any of the Core or Framework files or configurations, is it possible to get a hold on the Autofac container from the module and inject this interface from there through either code or XML config?
  3. Do you see any other options that I'm missing or am I going about this the wrong way?

Thanks so much in advance.  I'm really excited to be working with an active community on a really cool project.

Best Regards,

Apr 23, 2011 at 2:43 PM

Hi Steve,

I actually saw an example of this yesterday in sebastien's Media Folder module:

    public class RemoteStorageProvider : IStorageProvider {



I think OrchardSuppressDependency might be what you're after.

Sounds like a great feature btw!

Apr 23, 2011 at 5:29 PM

Exactly, as the ResourceManager has a single implementation running at a time, you have to switch the default one by this other. Another solution is to change the Priority property of the feature, as explained in a recent Blog post from Bertrand.

Apr 23, 2011 at 5:48 PM

That did it.  Many thanks for the quick responses guys!  Loving Orchard more and more each day.  Great job to everyone who's contributed thus far.

Best Regards,