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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:57:24+00:00 2026-05-27T09:57:24+00:00

I have following situation: public interface IFormater { StyleInformation GetStyleInformation(Fact fact); FactType[] Formats {

  • 0

I have following situation:

public interface IFormater
    {
        StyleInformation GetStyleInformation(Fact fact);
        FactType[] Formats { get; }
    }

public const string STYLENAME = "ABZ Date Style";

        ILocalization localization;

        public DateFormater(ILocalization localization)
        {
            this.localization = localization;
        }

        public StyleInformation GetStyleInformation(Fact fact)
        {
            return new StyleInformation(STYLENAME, false, false, false, false, false, true, localization.DateFormat);
        }

        public FactType[] Formats
        {
            get { return new FactType[] { FactType.Date }; }
        }

public class FormattingFacade
    {
        List<IFormater> formatters;
        IWindsorContainer container;

        public FormattingFacade(IWindsorContainer container)
        {
            this.container = container;
            formatters = new List<IFormater>();
            var formaterInterface = typeof(IFormater);
            foreach (Type type in this.GetType().Assembly.GetTypes())
            {
                if (formaterInterface.IsAssignableFrom(type) && !type.Equals(formaterInterface))
                {
                    container.Register(Component.For(new Castle.Core.ComponentModel(type.FullName, type, type)));
                    formatters.Add((IFormater)container.Resolve(type));
                }
            }
        }

        public StyleInformation GetStyleInformation(Fact fact)
        {
            foreach (IFormater formater in formatters)
                if (formater.Formats.Contains(fact.Concept.XbrlBaseType)) return formater.GetStyleInformation(fact);
            throw new NoFormaterException();
        }
    }

The problem is that castle throws exception when tries to resolve formater that has some parameters in constructor. If there is formater with only no arg constructor it works.
How should I register and how should I resolve these types but to keep this level of flexibility.

  • 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-27T09:57:25+00:00Added an answer on May 27, 2026 at 9:57 am

    I solved it this way:

    int i = 0;
    foreach (Type type in this.GetType().Assembly.GetTypes())
    {
            if (formaterInterface.IsAssignableFrom(type) && !type.Equals(formaterInterface))
            {
                    container.Register(Component.For<IFormater().ImplementedBy(type).Named(i.ToString()));
                    formatters.Add(container.Resolve<IFormater>(i.ToString()));
                    i++;
            }
    }
    

    I just registered components with generic aproach and to be able to do that I named each one of them by number key. I tested this one. It’s working well.

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

Sidebar

Related Questions

I have the following situation: // A public interface of some kind public interface
I have the following situation: Interface public interface Ranged{ public Object getRangeStart(); public Object
I have following component composition: public interface IJob { ILogger Logger { get; set;
I have the following situation: class Foo { public: static const Foo memberOfFoo; ........
Suppose you have the following situation #include <iostream> class Animal { public: virtual void
I have following situation, String a=<em>crawler</em> <em> Yeahhhhh </em></a></h3><table; System.out.println(a.indexOf(</em>)); It returns the 11
I have following situation: String a = A Web crawler is a computer program
I have the following situation: function Mach3Code(Str: String): String; var StrOut: String; begin StrOut
I have the following situation: Three concrete service classes implement a service interface: one
Imagine I have the following situation: Test1.java import java.lang.ref.WeakReference; public class Test1 { public

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.