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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:33:23+00:00 2026-05-16T07:33:23+00:00

I have to support a new input file format in a system which uses

  • 0

I have to support a new input file format in a system which uses Windsor. I also need to support the old version of the input file during a transition phase.
This will probably be repeated in future, and we’ll again need to support the new and the next most recent format.

The import processing is handled by a component, and the new version has had significant improvements in the code which makes it lots more efficient compared to the old version. So what I’d like to do is to have the new component and the old component in the system, and dynamically use the new or the old component based upon the file metadata.

Is there a pattern for this type of scenario anyone can suggest?

  • 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-16T07:33:24+00:00Added an answer on May 16, 2026 at 7:33 am

    The fact that you’re using Windsor is pretty much irrelevant here. Always strive to find a container-independent solution. Here’s one:

    interface IImportProcessor {
        bool CanHandleVersion(int version);
        Stream Import(Stream input);
    }
    
    class ImportProcessorVersion1 : IImportProcessor {
        public bool CanHandleVersion(int version) {
            return version == 1;
        }
    
        public Stream Import(Stream input) {
            // do stuff
            return input;
        }
    }
    
    class ImportProcessorVersion2 : IImportProcessor {
        public bool CanHandleVersion(int version) {
            return version == 2;
        }
    
        public Stream Import(Stream input) {
            // do stuff
            return input;
        }
    }
    
    class MainImportProcessor: IImportProcessor {
        private readonly IImportProcessor[] versionSpecificProcessors;
    
        public MainImportProcessor(IImportProcessor[] versionSpecificProcessors) {
            this.versionSpecificProcessors = versionSpecificProcessors;
        }
    
        public bool CanHandleVersion(int version) {
            return versionSpecificProcessors.Any(p => p.CanHandleVersion(version));
        }
    
        private int FetchVersion(Stream input) {
            // do stuff
            return 1;
        }
    
        public Stream Import(Stream input) {
            int version = FetchVersion(input);
            var processor = versionSpecificProcessors.FirstOrDefault(p => p.CanHandleVersion(version));
            if (processor == null)
                throw new Exception("Unsupported version " + version);
            return processor.Import(input);
        }
    }
    

    Your app would take a dependency on IImportProcessor. The container is wired so that the default implementation of this interface is MainImportProcessor. The container is also wired so that MainImportProcessor gets all other implementations of IImportProcessor.
    This way you can add implementations of IImportProcessor and each will be selected when appropriate.

    It might be easier to wire things up if MainImportProcessor implements an interface different from IImportProcessor.

    Another possibility could be implementing a chain of responsibility.

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

Sidebar

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.