how to implement code changes without altering core classes

Topics: Customizing Orchard
Jun 17, 2013 at 3:10 PM
I have managed to alter ItemInspector class in Orchard.Core.Feeds.StandardBuilders in order to get a different RSS result.I have the desired functionality now, but i know that It s not the best practice to change core classes.
So what i have to do if i want to keep intact ItemInspector class in Orchard.Core but also want the new functionality?Should I create a new module just only for this slight change and what i have to include in this module?
I just want a general guideline ,not code :)
Thanx in advance!
Developer
Jun 17, 2013 at 4:56 PM
If you think the change is something that should be in core, submit a pull request.

If you think the change is something isolated to you, copy the code to another class and use the OrchardSuppressDependency attribute (http://www.rolandthompson.co.uk/roland-thompson-blog/orchard---using-the-orchardsuppressdependency-attribute)
Jun 18, 2013 at 8:23 AM
Thanks for the tip Jetski5822!

I have already implemented Roland Thompson's tutorial but no results for me.
Actually I created a new module as the documentation says.
The only thing i ve added is a new folder -->StandardBuilders
Inside the new folder i have implemented MyItemInspector class that is a variation of ItemInspector in
Orchard.Core.Feeds.
I have also used the attribute OrchardSuppressDependency
[OrchardSuppressDependency("Orchard.Core.Feeds.StandardBuilders.ItemInspector")]
public class MyItemInspector 
{
   //my code here
}
I ve include in the .csproj file of the module these lines
  <ItemGroup>
       <Compile Include="StandardBuilders\MyItemInspector.cs" />
  </ItemGroup>
I enabled the module but i do not have the desired result.When i m debbuging still the system calls orchard.core.feeds ItemInspector class
and not mine.
Where is my mistake?
Developer
Jun 18, 2013 at 9:44 AM
Ahhhh because OrchardSuppressDependency only suppresses stuff that goes through DI to which ItemInspector does not.

Okay, can I ask what changes you have made?
Jun 18, 2013 at 10:23 AM
the only actual change is that i altered the return string of public string Description
    return img+_htmlFilters.Aggregate(_body.Text, (text, filter) => filter.ProcessContent(text, GetFlavor(_body)));
where img is a string that i create