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

  • SEARCH
  • Home
  • 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 8453081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:40:34+00:00 2026-06-10T11:40:34+00:00

I am consuming several different providers that implements the same Interface, instantiating and accessing

  • 0

I am consuming several different providers that implements the same Interface, instantiating and accessing them through an object factory.

I get the data from these different providers attaching to events. Each one of these providers have their own CustomEventArgs, which differs between providers…

Could you suggest an approach to manage the event (with the different eventArgs) in a “centralized” way? Something like casting Events? Just in case I want to do always the same behavior on events, like assing string properties to Label on IU.

  • Could I implement something like an intermediate class to listen the several event(with the different eventArgs) and then onEvent can raise a new MyEvent with MyOwnEventArgs that contains the sum of all the particular properties of the several CustomEventArgs from the providers? Is there an advantege on this?

  • Could I implement something like an intermediate class to listen the several event(with the different eventArgs) and then onEvent can raise a new MyEvent with MyOwnEventArgs that contains just one IDictionary property where each Item contains the name and value of all the particular properties of the several CustomEventArgs from the providers? Is there an advantege on this?

  • Is there any other way to read the “different” properties (different property name) from several CustomEventArgs in easy way?

  • 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-06-10T11:40:36+00:00Added an answer on June 10, 2026 at 11:40 am

    Sounds like a good match for the adapter pattern to transform all the different event classes to your own event class.

    If the providers follow the event pattern properly you’ll get the provider in the source argument.

    So you can do something like this:

    interface IEventAdapter
    {
        CustomEventArgs Transform(EventArgs E);
    }
    
    public class EventListener
    {
        Dictionary<Type, IEventAdapter> _adapters;
    
        public void Map(Type providerType, IEventAdapter adapter)
        {
            _adapters.Add(providerType, adapter);
        }
    
        public void Subscribe(IProvider provider)
        {
            //hook event
        }
    
        protected void OnEvent(object source, EventArgs e)
        {
            var theArgs = _adapters[source.GetType()].Adapt(e);
            TheEvent(source, theArgs);
        }
    
        public EventHandler<CustomEventArgs> TheEvent;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We work on several different branches of the same code, and when working on
I have a query that I run several times with different parameters. I am
In a cocoa application that I'm writing, I want to create several different kinds
While consuming SOAP service, I am getting this error. I just dun get it
When consuming a .NET WCF webservice I get the following response (error): Unsupported HTTP
I am consuming a cpp COM object from c# code. My c# code looks
I am consuming some JSON from two different sources, I end up with two
I have a need to archive an array of objects of several different types.
My understanding of a factory is that it encapsulates instantiation of concrete classes that
I have an Open GL application that renders a simulation animation and outputs several

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.