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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:14:57+00:00 2026-05-20T19:14:57+00:00

I want to make small framework with i could simply invoke webservices on many

  • 0

I want to make small framework with i could simply invoke webservices on many computers that have webservice.

So, i have i.e five computers with webservices.
Each ws provides 2 functions (could be more, but this is example):
DataFormat[] GetXData(int)
Something[] GetYData(string, int).

Invoking service now looks like this:
ServiceClient wsc;
DataFormat[] data = wsc.GetXData(5);

I plan interface of framework like this:

MultiWebservice mws;
DataFormat[] data = mws.BroadcastQuery( wsc.GetXData(5) );

As can see, i wish to inject function with iam interested to fire on every ws. And return merged data (merging is not subject of post. i handle it myself)

I need a help how use C# to make this elegant, generic and if it isn’t necessary,
without many overloading of function because i don’t want make new overloadings for each different return type or
each function in ws.

Please, give me advice. Maybe this interface is wrong and could be better.

  • 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-20T19:14:58+00:00Added an answer on May 20, 2026 at 7:14 pm

    To give an answer similar to Thomas Li’s, but using a generic type parameter for the methods, to allow any return type:

     public class WSClient {
          public int GetPower (int var) { return var * var; }
          public int[] GetDuplicatePowers (int var) {
                  return new[] { GetPower(var), GetPower (var) };
          }
     }
    
     public class Multiplexer<T> {
          IList<T> _sources;
          public Multiplexer (IEnumerable<T> sources) {
                 _sources = new List<T> (sources);
          }
    
          public IEnumerable<TResult> Call<TResult> (Func<T, TResult> func) {
              return _sources.Select (s => func(s));
          }
    
          public IEnumerable<TResult> AggregateCall<TResult> (Func<T, IEnumerable<TResult>> func) {
              return _sources.SelectMany (s => func(s));
          }
     }
    
     public class Test {
         public static void Main (string[] args) {
               var m = new Multiplexer<WSClient> (new[] { new WSClient (), new WSClient () });
               var powers = m.Call (c => c.GetPower (2));
               var agg_powers = m.AggregateCall (c => c.GetDuplicatePowers (2));
         }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small PHP framework which I want to make available for download.
I have written a small PHP framework and I want to make a website
I have one small online sale business but I want to make it scalable
I'm trying to create a small javascript framework that can make it easier when
A researcher has created a small simulation in MATLAB and we want to make
I have style sheet with a class name changebackgroundcolor i want make change in
I want to make an etag that matches what Apache produces. How does apache
I want to make a table in SqlServer that will add, on insert, a
I want to make an entity that has an autogenerated primary key, but also
I have an existing website that I need to develop a small portion of

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.