public virtual void ComponentRegistration_Activating(object sender, Autofac.Core.ActivatingEventArgs <object> e) { object instance = e.Instance; TypeInfo instanceType = instance.GetType().GetTypeInfo(); if (IsGoingToCreateProxyForImplementationType(instanceType)) { instance = _createProxyForService.MakeGenericMethod(instanceType).Invoke(this, new[] { instance }); e.ReplaceInstance(instance); } if (Objects is BlockingCollection <object> blockingCollection) { blockingCollection.Add(instance); } else if (Objects is ICollection <object> collection) { collection.Add(instance); } else { throw new NotSupportedException($"Provide compatible collection type for {nameof(Objects)}"); } }
public virtual void ComponentRegistration_Activating(object sender, Autofac.Core.ActivatingEventArgs <object> e) { object instance = e.Instance; TypeInfo instanceType = instance.GetType().GetTypeInfo(); if (IsGoingToCreateProxyForImplementationType(instanceType)) { instance = _createProxyForService.MakeGenericMethod(instanceType).Invoke(this, new[] { instance }); e.ReplaceInstance(instance); } Objects.Add(instance); }