public T Activate <T>(string typeName, Action <string> errorAction, T defaultInstance = null) where T : class { if (FakedType.Key == typeName) { Console.WriteLine("Requested type to activate matches the configured faked type, returning the faked instance"); return((T)FakedType.Value); } Console.WriteLine("Requested type to activate does not match, forwarding call to the regular type activator"); return(_normalTypeActivator.Activate <T>(typeName, errorAction, defaultInstance)); }
public void OnTypesLoaded(ITypeActivator typeActivator, IEnumerable <Type> discoveredTypes) { var typeResolverFactories = new List <ITypeResolverFactory>(); foreach (var type in discoveredTypes) { if (typeof(ITypeResolverFactory).IsAssignableFrom(type)) { ITypeResolverFactory factory = typeActivator.Activate <ITypeResolverFactory>(type); Logging.Log.Info("Discovered Type Resolver : " + type.GetDescription()); typeResolverFactories.Add(factory); } } _typeResolverFactoryRepository = new TypeResolverFactoryRepository(typeResolverFactories.ToArray()); }