Need to override method that is in a namspace with another class which constructs it

169 views Asked by At

I am trying to override a method on a control in the Community Server SDK called 'InlineTagsContainerTagEditor'.

When I find the source for this control, it is inside of a file with another class called 'TaggableContentTagEditableList'.

Here is what I think the relevant parts are:

namespace CommunityServer.Controls
{
    public class TaggableContentTagEditableList : WrappedContentBase, ICallbackEventHandler
    {
       protected virtual InlineTagsContainerTagEditor GetInlineTagEditor(ITagsContainer container)
        {
            return new InlineTagsContainerTagEditor(container);
        }

    }
    public class InlineTagsContainerTagEditor : TWC.InlineEditor
    {
        ITagsContainer _container;

        public InlineTagsContainerTagEditor(ITagsContainer container)
            : base()
        {
            _container = container;
        }

    }
}

I am just trying to create a version of the TaggableContentEditableList which removes certain 'tags'. The method for that I have attempted to override below - but I get very lost. Do I have to override the constructor for TaggableContentTagEditableList in order to have the constructor look for the correct type with my overriden method?

public partial class TaggableContentEditableListExclude : TaggableContentTagEditableList
{
    protected override InlineTagsContainerTagEditor GetInlineTagEditor(ITagsContainer container)
    {
        return new TagExcludeOption(container);
    }
}

public partial class TagExcludeOption : InlineTagsContainerTagEditor
{
    ITagsContainer _container;

    public TagExcludeOption(ITagsContainer container) : base(container)
     {
        _container = container;
    }

    public override string FormatTags(string[] tagList)
    {
        // strip special tags
        string[] newTagList = stripTags(tagList);
        return base.FormatTags(newTagList);
    }

    private string[] stripTags(string[] tagList)
    {
        //doing something here
    }
}
1

There are 1 answers

0
Jeff Martin On BEST ANSWER

Your problem seems to be in your override FormatTags

You are creating a new string with your stripped tags but then you send the old string into the base.

The old string hasn't been altered so your override isn't doing anything.

Try

public override string FormatTags(string[] tagList)
{
    // strip special tags
    string[] newTagList = stripTags(tagList);
    return base.FormatTags(newTagList);
}