我基本上遵循这个guide,除了我正在为Objects而不是文档编写代码。这是我的代码:
using CMS.TreeEngine;
using CMS.SettingsProvider;
[CustomObjectEvents]
public partial class CMSModuleLoader
{
/// <summary>
/// Attribute class that ensures the loading of custom handlers
/// </summary>
private class CustomObjectEventsAttribute : CMSLoaderAttribute
{
/// <summary>
/// Called automatically when the application starts
/// </summary>
public override void Init()
{
// Assigns custom handlers to the appropriate events
ObjectEvents.GetContent.Execute += Category_Get_Content; //error is here
}
private void Category_Get_Content(object sender, DocumentEventArgs e)
{
// Add custom actions here
}
}
}
上面的行引发编译时错误:
错误1无法将方法组“Category_Get_Content”转换为非委托类型“CMS.SettingsProvider.SimpleObjectHandler”。你打算调用这个方法吗? C:\ APPLICATIONS \ DEVELOPMENT \ KENTICO6 \ WebPartDev \ wwwroot \ App_Code \ Blank Site \ SearchByCategory.cs 22 40 C:... \ wwwroot \
有什么想法吗?
答案 0 :(得分:1)
我必须在Category_Get_Content方法中将DocumentEventArgs
更改为ObjectEventArgs
。