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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:44:03+00:00 2026-05-24T04:44:03+00:00

In Caliburn.Micro documentation the authors mention such possibility: documentation link IHandle inherits from a

  • 0

In Caliburn.Micro documentation the authors mention such possibility:

documentation link

IHandle inherits from a marker interface IHandle. This allows the use of casting to determine if an object instance subscribes to any events. This enables simple auto-subscribing if you integrate with an IoC container. Most IoC containers (including the SimpleContainer) provide a hook for being called when a new instance is created. Simply wire for your container’s callback, inspect the instance being created to see if it implement IHandle, and if it does, call Subscribe on the event aggregator.

How is it possible to achieve this with Autofac?

I tried to utilize the features of decorator, but of course it’s kinda improper for this case. More over, by default my implementors of IHandle<> are not getting registered as instances of IHandle within the container.

P.S. Providing this improper implementation just in case it might be of any use, though I doubt.

builder.RegisterInstance<IEventAggregator>(new EventAggregator());
builder.RegisterDecorator<IHandle>((container, handler) =>
{
    var eventAggregator = container.Resolve<IEventAggregator>();
    eventAggregator.Subscribe(handler);
    return handler;
}, "unsubscribed", "subscribed");
  • 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-24T04:44:04+00:00Added an answer on May 24, 2026 at 4:44 am

    Making a few assumptions about how Caliburn works, I think what you’re looking for is:

    builder.RegisterType<MyViewModel>();
    builder.RegisterModule<AutoSubscribeHandlersModule>();
    

    Where the module is implemented something like:

    class AutoSubscribeHandersModule : Module
    {
        protected override AttachToComponentRegistration(
            IComponentRegistry registry,
            IComponentRegistration registration)
        {
            if (typeof(IHandle).IsAssignableFrom(registration.Activator.LimitType))
            {
                registration.Activated += (sender, e) => {
                    var aggregator = e.Context.Resolve<IEventAggregator>();
                    aggregator.Subscribe((IHandle)e.Instance);
                };
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Caliburn.Micro documentation the authors mention such possibility: documentation link IHandle inherits from a
I upgraded Caliburn.micro and had a breaking change from 1.0 to 1.1 - method
This is specifically a Caliburn.Micro question I think, as it has to do with
I have this Caliburn.Micro sample project I'm putting together and I am having trouble
I use caliburn micro and MEF in wpf and I have this problem. I
This was posted at Caliburn.Micro discussions also. I'm really looking for advice and opinions
Hi I bind collection from Caliburn Micro on ListBox control in view. Here is
Hi I create simpel MDI in caliburn micro something like this : http://devlicio.us/blogs/rob_eisenberg/archive/2010/10/19/caliburn-micro-soup-to-nuts-part-6c-simple-mdi-with-screen-collections.aspx .
I'm quite new to Caliburn.Micro, so I guess this has a simple answer (or
Progressbar and Caliburn Micro Hello All, This is my first project using Caliburn so

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.