それを構築し、他のクラスと名前空間にあるメソッドをオーバーライドする必要があります

StackOverflow https://stackoverflow.com/questions/664229

質問

私は「InlineTagsContainerTagEditor」と呼ばれるコミュニティサーバーSDKでコントロールのメソッドをオーバーライドしようとしています。

私は、このコントロールのソースを見つけたら、

、それがTaggableContentTagEditableList 'と呼ばれる別のクラスでのファイルの中にある。

ここで私は、関連する部分があると思いますものです。

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;
        }

    }
}

私は、特定の「タグ」を除去しTaggableContentEditableListのバージョンを作成しようとしています。そのための方法は、私は以下の上書きしようとしてきた - しかし、私は非常に迷子になります。私はオーバーライドされたメソッドで正しい型のコンストラクタの外観を持つためにTaggableContentTagEditableListのコンストラクタをオーバーライドする必要がありますか?

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
    }
}
役に立ちましたか?

解決

あなたの問題は、あなたのオーバーライドFormatTags内にあるように見えます。

あなたは取り除かタグを持つ新しい文字列を作成しているが、その後、あなたはベースに古い文字列を送ってます。

古い文字列は、あなたのオーバーライドが何もしていませんので、変更されていない。

試してみてください。

public override string FormatTags(string[] tagList)
{
    // strip special tags
    string[] newTagList = stripTags(tagList);
    return base.FormatTags(newTagList);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top