Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3489884
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:26:57+00:00 2026-05-18T11:26:57+00:00

I’m struggling with the code below. I have a method Find, which for me

  • 0

I’m struggling with the code below.

I have a method Find, which for me is generic in terms I can use it for different type deriving from the same base class. Inside this method I used to have a delegate passed to the FindAll call. I removed this delegate and I’m trying to pass it as parameter, so more methods can use the Find method with different filtering criteria.

The problem is that the Filter delegate must be able to accept a Template type as argument, and the compiler is complaining that the parameters to the Find method doesn’t match. The problem happens inside the method FindItems when I call Find.

Any ideas? Many thanks

    delegate bool FindFilter<T_Item>(T_Item item);

    private List<MailItem> Find<T_Item, T_Adaptor>(T_Adaptor adaptor, MailItemId mailId, FindFilter filter)
    {
            List<T_Item> tempList = ((List<T_Item>)(typeof(T_Adaptor).InvokeMember(
                    "Load",
                    BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
                    null, adaptor,
                    new Object[] { null, mailId, null })));

            totalItemsFound = tempList.Count;

            List<T_Item> Items = tempList.FindAll(
                            filter()
                        );

        List<MailItem> mailItems = new List<MailItem>();
        foreach (T_Item itm in Items)
            mailItems.Add(itm as MailItem);

        return mailItems;
    }

        private static bool FindAssignedItemsOnly<T_Item>(T_Item itm)
        {
            MailItem mi = itm as MailItem;
            if (mi == null) return false;
            return (mi.StateInd.Code == StateInd.ASSIGNED);
        }

    public List<MailItem> FindItems(MailItemId itemId, string mailCategoryCd)
    {
        List<MailItem> mailItems = new List<MailItem>();

            FindFilter<MailItem> f = FindAssignedItemsOnly;
           // Problem happens in the line below
            mailItems = Find<Letter, BasicItemAdapter>(new LetterItemAdapter(), itemId, f); 

        return mailItems;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:26:57+00:00Added an answer on May 18, 2026 at 11:26 am

    I made some changes:

    to FindItems, change f to FindFilter<BasicItem>:

        FindFilter<BasicItem> f = FindAssignedItemsOnly;
        // Problem happens in the line below
        mailItems = Find<BasicItem, BasicItemAdapter>(new BasicItemAdapter(), itemId, f);
    

    and to Find, use the FindFilter generic type:

     private List<MailItem> Find<T_Item, T_Adaptor>(T_Adaptor adaptor,
        MailItemId mailId, FindFilter<T_Item> filter)
    

    and changed the main search:

    List<T_Item> Items = tempList.FindAll(row => filter(row));
    

    and it compiles; obviously I can’t test it since I had to invent a lot of code…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.