public void Inject(Exported exported) { _exported = exported; Assert.Equal(1, i); Console.WriteLine($"Injected {i++}"); }
public static IRecordProcessor LoadRecordProcessor(Assembly Dynamic) { Type TypeofIRecordProcessor = typeof(IRecordProcessor); foreach (Type Exported in Dynamic.GetExportedTypes()) { if (TypeofIRecordProcessor.IsAssignableFrom(Exported)) { //return (IRecordProcessor)Activator.CreateInstance(InputElementClass); ConstructorInfo Constructor = Exported.GetConstructor(System.Type.EmptyTypes); if (Constructor == null) { throw new Exception("Failed to bind " + Dynamic.FullName + ". Classes has no proper Constructor"); } // Type supports IMatch and has an no-parameter constructor IRecordProcessor Instance = (IRecordProcessor)Constructor.Invoke(System.Type.EmptyTypes); return(Instance); } } throw new Exception("Failed to bind " + Dynamic.FullName + ". No acceptable Classes found"); }
public ModelRequest LoadModel(string assemblyFilename, string request) { Assembly Dynamic = Assembly.LoadFrom(assemblyFilename); Type TypeofIModel = typeof(IModel); foreach (Type Exported in Dynamic.GetExportedTypes()) { if (TypeofIModel.IsAssignableFrom(Exported)) { ConstructorInfo Constructor = Exported.GetConstructor(Type.EmptyTypes); if (Constructor != null) { IModel instance = (IModel)Constructor.Invoke(null); ModelRequest modelRequest = new ModelRequest(instance, request); return(modelRequest); } } } // if no matches return(null); }
private void OnExported(List <ILibraryEntity> arg1, string arg2, FileStorageType arg3) { Exported?.Invoke(arg1, arg2, arg3); }