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 618969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:36:16+00:00 2026-05-13T18:36:16+00:00

Imagine I have a C# app sitting on a server somewhere that is creating

  • 0

Imagine I have a C# app sitting on a server somewhere that is creating instances of the Item class and publishing them on a messaging service.

class Item
{
    public int ID1, ID2, ID3;
    public double Value1, Value2, Value3;
}

Now I have another C# app on a desktop somewhere listening to these messages. I want to be able to create callbacks based on specified values of the ID# fields. For example, “call this method whenever a message comes in where ID1 = 2, ID2 = 160, and ID3 = anything”. I think this would be straightforward if I used string key-value pairs, but ideally I could do this without giving up static typing. I imagine this requires reflection, but I’m not entirely sure where to start.

I’m picturing the app creating an instance of Item with the required ID# values (let’s say -1 means unspecified), and passing that into a RegisterCallback method of some object ItemListener. Then whenever ItemListener receives a new Item message, it can check for any callbacks that match, and act accordingly. Is this a reasonable design? Any suggestions on what to look at to implement it?

  • 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-13T18:36:16+00:00Added an answer on May 13, 2026 at 6:36 pm
    class ConditionalCallback()
    {
         public Predicte<Item>   Predicate {get; set;}
         public Action<Item>     Callback  {get; set;}
    }
    
    List<ConditionalCallback> callbacks = new List<ConditionalCallback>();
    
    public AddCallBack(Predicte<Item> pred, Action<Item> callback)
    {
        callbacks.Add(new ConditionalCallback { 
                                  Predicate = pred, 
                                  Callback = callback
                                   });
    }
    
    
    void HandleItem(Item item)
    {
         foreach(var cc in callbacks)
             if (cc.Predicate(item))    
                 cc.Callback(item);
    }
    
    // 
    
    AddCallBack( i=> i.ID1 = 2 && i.ID2 = 160 && i.ID3 = anything", MyCallback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im playing a little bit with heavy-client app. Imagine I have this model: class
Imagine you're writing a web app that will have 1 million users (they all
Imagine you have an app that manages some library and has its own data.
I have a vertically scrolling uiscrollview - imagine an 'about this app' page of
Imagine you are developing a Java EE app using Hibernate and JBoss. You have
Imagine you have an entity that has some relations with other entities and you
Imagine you have a large dataset that may or may not be filtered by
Imagine you have one page app using Javascript MVC, which should switch between sub-apps
Imagine you have an aspect: @Aspect public class MyAspect { @Pointcut(whatever) public void anyAnnotation()
well, I have my Android app that have 4 main options. For that I

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.