我有另一個簡單的(我認爲)這是困擾着我。我已經在我的一個控件中編寫了一個方法,該方法在CMS中給出文件的最新版本(即文件的文件夾位置)。我發現它非常有用,因爲我認爲我將它放在我的CMSToolbox類中,但是當我這樣做時,我不能再使用CMS提供的FileManager類的Where()
方法(它將返回一個列表)。C#初學者:我的IList.Where()方法在哪裏去了?
這是我班的一個簡單的例子:
using System;
using System.Collections.Generic;
using CMS.CMS;
using CMS.Core;
using CMS.Web;
namespace CoA.CMS {
public class ToolBox
{
public CMS.CMS.File getLatestFileVersionByFilename(string filename, int GroupID)
{
IList<CMS.CMS.File> fileWithName = FileManager.GetGroupAll(false, GroupID).Where(file => currentFileVersionIsNamed(file, filename)).ToList<CMS.CMS.File>();
return getLatestFileFromListOfFiles(fileWithName);
}
protected bool currentFileVersionIsNamed(CMS.CMS.File file, string name)
{
}
protected CMS.CMS.File getLatestFileFromListOfFiles(CMS.CMS.File file)
{
}
}
}
當我做同樣的事情在控制我有機會獲得Where()
(真由延伸Control
的CMS提供的一類)的情況下方法,但在我的ToolBox類中,我沒有。是什麼賦予了?我認爲IList
總是允許從任何地方訪問相同的方法。
我是錯了,哈哈:)
編輯:Filemanager.GetGroupAll()
返回CMSList
延伸IList
你,先生,是絕對的bl ** dy傳奇!做得好! :) –