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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:36:51+00:00 2026-05-14T03:36:51+00:00

I am wrapping a number of functions from a vender API in C#. Each

  • 0

I am wrapping a number of functions from a vender API in C#. Each of the wrapping functions will fit the pattern:

public IEnumerator<IValues> GetAggregateValues(string pointID, DateTime startDate, DateTime endDate, TimeSpan period) {
   // Validate Data
   // Break up Requesting Time-Span
   // Make Requests
   // Read Results (through another method call
}

5 of the 6 requests are aggregate data pulls and have the same signature, so it makes sense to put them in one method and pass the aggregate type to avoid duplication of code. The 6th method however follows the exact same pattern with the same result-set, but is not an aggregate, so no time period is passed to the function (changing the signature).

Is there an elegant way to handle this kind of situation without coding a one-off function to handle the non-aggregate request?

  • 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-14T03:36:51+00:00Added an answer on May 14, 2026 at 3:36 am

    There are definitely ways to handle this:

    1. Make the time-period parameters nullable (DateTime? or Nullable<DateTime>)
    2. Create a struct or class to hold the “parameters” to the function, including more or less information as needed.
    3. Pull the code inside your existing function into several smaller functions, then put them back together into the two separate functions you need, avoiding most of the duplication while keeping completely separate functions/signatures.

    Note that for 1 and 2, you’ll need to check for these conditions and use/skip some code inside the function based on the values.

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

Sidebar

Related Questions

I am working on wrapping a large number of .h and .lib files from
I'm using Ghostscript library API (wrapping from C#) to print PDF documents from my
I am wrapping existing C++ code from a BSD project in our own custom
Our framework requires wrapping certain functions in some ugly boilerplate code: def prefix_myname_suffix(obj): def
I want to extract the number '123' from this: <div class=f_right style=padding-top:5px;>123</div> What regular
I have a number of devices from which i need to get status updates.
Wrapping a JavaScript class? Below is a simple class for displaying messages. It stores
Still wrapping my head around Delegates and I'm curious: Is it possible to overload
To prevent wrapping of a part of text, surrounding that part in a <span
I'm wrapping my brain around mobile sites using jquerymobile's framework. So far I have

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.