Category: rscg composite provider

RSCG-Composite Provider – part 2 -execution

Imagine this: For every interface IA you create:

  1. Your composite provider implements IA seamlessly
  2. In the constructor, pass an array of IA providers
  3. Each method returns the first successful value from your array of providers
  4. For even better performance, use a boolean flag to optimize by reusing previous successes

The RSCG_CompositeProvider package doesnΓÇÖt just solve the obvious issuesΓÇöit handles the tricky ones too:

  • Exception Handling: What if one of your providers throws an error? No worries, it moves on to the next provider without skipping a beat.
  • Asynchronous Methods: Supports `Task` returns so you can handle async operations with ease.
  • Async Enumerables: Easily works with `IAsyncEnumerable` for streaming data in chunks.

I will let you think how to solve this – you can find my solution at https://github.com/ignatandrei/RSCG_CompositeProvider

And the best news? It’s already been tested: with over 20 tests covering every edge case, you can trust this library to handle your toughest challenges.

Get started with RSCG-Composite Provider, available via NuGet: http://nuget.org/packages/RSCG_CompositeProvider.

RSCG-Composite Provider – part 1 -idea

API Outage solved with local data

The problem that I try to solve is : How an UI can have data to show , even if the API from where it gathers data does not work ?

Imagine having a robust system that adaptively switches between retrieving data from multiple sources – including internal APIs, memory-based storage, or even JSON files near the UI. This flexibility makes all the difference when working with complex systems that may suddenly lose their external connectivity.

This could be solved with interfaces and a composite provider ( see http://msprogrammer.serviciipeweb.ro/2025/03/10/pattern-compositeprovider/ )

How It Works:

  • You have an interface defining how your UI fetches data.Easy peasy!
  • One implementation pulls data from the trusty API, ideally when it’s up and running smoothly.
  • Another implementation acts as a backup hero, pulling data from a local JSON file or even hard-coded values.

And the best part? The composite provider handles switching between these sources seamlessly. No more coding headaches – it just works!

Making It Even Easier: Roslyn Code Generator to the Rescue

Tired of writing boilerplate code for this pattern every time? Please give a chance to a new Roslyn Code Generator (https://www.nuget.org/packages/RSCG_CompositeProvider). It automatically generates the composite providers you need, cutting down on repetitive work and letting you focus on what really matters – building awesome apps!

Andrei Ignat weekly software news(mostly .NET)

* indicates required

Please select all the ways you would like to hear from me:

You can unsubscribe at any time by clicking the link in the footer of our emails. For information about our privacy practices, please visit our website.

We use Mailchimp as our marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.