| 

.NET C# Java Javascript Exception

1
Hallo,

ich bin beim Debugen grad auf was gestoßen was ich mir nicht erklären kann :


[ImportMany(typeof(IModule.IModule),AllowRecomposition = true)]
private IModule.IModule[] _modules;

[ImportMany(typeof (IGenericRepository.IRepository))]
private IGenericRepository.IRepository[] _repos;

[ImportMany(typeof (IFileSearcher.IFileSearcher))]
private IFileSearcher.IFileSearcher[] _fileSearcher;

[ImportMany(typeof(IFileUploader.IFileUploader))]
private IFileUploader.IFileUploader[] _fileUploader;

Für jedes Interfaces rufe ich eine Private Methode auf z.B.
private void LoadModuleExtensions()
{
var dirCatalogModules = new DirectoryCatalog("Modules");
var container = new CompositionContainer(dirCatalogModules);
CompositionBatch compBatch = new CompositionBatch();
compBatch.AddPart(this);
compBatch.AddPart(dirCatalogModules);
container.Compose(compBatch);
}

Bei meinen Modulen ist das Array nach der ersten Methode gefüllt, sobald er aber danach eine Methode zum Füllen der FileUploader ausführt, sind meine Module wieder leer Oo.

Habe ich was übersehen ?



Grüße
21.02.2011
Pawel Warmuth 195 5
1 Antwort
0
So hier nun meine Antwort :

Wenn ich mir eigene ComposerKlassen pro Typ schreibe klappat alles wunderbar zB.
class RepositoryComposer:IDisposable
{
[ImportMany(typeof(IGenericRepository.IRepository), AllowRecomposition = true)]
private IEnumerable<IGenericRepository.IRepository> Modules { get; set; }

public List<IGenericRepository.IRepository> GetModules()
{
AggregateCatalog catalog = new AggregateCatalog();
catalog.Catalogs.Add(new DirectoryCatalog("Repository"));
CompositionContainer container = new CompositionContainer(catalog);
container.ComposeParts(this);
return Modules.ToList();
}

public void Dispose()
{
Modules = null;
}
}


Grüße
23.02.2011
Pawel Warmuth 195 5

Stelle deine .net-Frage jetzt!