private void Activating(IActivatingEventArgs <object> e) { var matchingAttachments = conventionManager.FindMatchingAttachments(e.Instance).Select(e.Context.Resolve); foreach (var attachment in matchingAttachments) { AttachmentHelper.Attach(attachment, e.Instance); } }
public void Configure(IEnumerable <Type> views, IEnumerable <Type> viewModels, IEnumerable <Type> attachments, IConventionManager conventionManager) { container.PropertyDependencySelector = new PropertyInjectionDisabler(); foreach (var type in views.Concat(viewModels).Concat(attachments)) { container.Register(type); } container.Initialize(registration => viewModels.Contains(registration.ServiceType), (factory, instance) => { var matchingAttachments = conventionManager.FindMatchingAttachments(instance) .SelectMany(factory.GetAllInstances); foreach (var attachment in matchingAttachments) { AttachmentHelper.Attach(attachment, instance); } }); }