C # Novice: Where did my IList.Where () method disappear?

I have one more simple (I think) that surpassed me. I wrote a method in one of my controls that gets the latest version of a file in CMS, given its file name (that is, regardless of which folder the file is in). I found this useful enough to think that I dropped it into my CMSToolbox class, but when I do this, I can no longer use the Where()FileManager class method provided by CMS (which returns a list).

Here is a simplified example of my class:

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)
        {
        }
    }
}

( , CMS, Control), Where(), ToolBox . ? , IList , .

, -:)


: Filemanager.GetGroupAll() a CMSList, IList

+3
3

using System.Linq. .Where() - IEnumerable<T> ( IList<T>), System.Linq.

+12

Joel , : Where() . - , :

static class NameNeverUsed
{
    public static void AnExtensionMethod(this string x)
    {
    }
}

:

"hello".AnExtensionMethod();

, , . , Java/++, , .

+3

IIRC that. Somewhere, the method is part of LINQ, and you need to add those that use the instructions in your class to get extension methods for the IEumerable interface.

0
source

Source: https://habr.com/ru/post/1723301/


All Articles