Bonsoir, je suis sur un problème depuis plusieurs heure et je lâche un peu l'affaire >< Le code est logique, je vois clairement pas d'où ça peut venir :/
J'ai une DLL :
Et une classe d'import :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 using System; using System.Collections.Generic; using System.Linq; using System.Text; using Google.YouTube; using Google.GData.Extensions.MediaRss; using Google.GData.YouTube; using Google.GData.Extensions.Location; using Google.GData.Client; using System.Net.Mime; using System.ComponentModel.Composition; namespace Modules { public interface IMyModuleUpload { string Name { get; } string MadeBy { get; } double Version { get; } void upload(string title, string description, string[] keywords, string path); } [Export] public class MyYoutube : IMyModuleUpload { const string _type = "Youtube"; const string _madeBy = "Xtroyer"; const double _version = 1.0; private string[] _idents; private YouTubeRequest _request; YouTubeRequestSettings _settings; public string Name { get { return _type; } } public string MadeBy { get { return _madeBy; } } public double Version { get { return _version; } } [ImportingConstructor] public MyYoutube([Import("Pseudo")]string pseudo, [Import("Password")]string password) { this._idents = new string[2] { pseudo, password }; _request = new YouTubeRequest(_settings); } public string[] Idents { get { return _idents; } set { _idents = value; } } public void upload(string title, string description, string[] keywords, string path) { /*Peu importe */ } } }
Mais je ne retrouve rien alors que j'ai bien mi la DLL dans le même dossier que le binaire fin, j'ai rien du tout dans le UploadService, ça me rend fou >< Des idées ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.Composition; using System.IO; using System.Reflection; using System.ComponentModel.Composition.Hosting; namespace ConsoleApplication3 { public interface IMyModuleUpload { string Name { get; } string MadeBy { get; } double Version { get; } void upload(string title, string description, string[] keywords, string path); } class ImportModuleUpload { [ImportMany(typeof(IMyModuleUpload))] public IEnumerable<IMyModuleUpload> UploadService { get; set; } public void run(string pseudo, string mdp) { this.Compose(pseudo, mdp); } private void Compose(string pseudo, string mdp) { string currentDirectory = new FileInfo(Assembly.GetCallingAssembly().Location).Directory.ToString(); AggregateCatalog catalog = new AggregateCatalog(new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog(currentDirectory)); var container = new CompositionContainer(catalog); container.ComposeExportedValue("Pseudo", pseudo); container.ComposeExportedValue("Password", mdp); container.ComposeParts(this); Console.WriteLine("Test : {0}", UploadService.Count()); } public void upload(string name, string title, string description, string[] keywords, string path) { } } class Program { static void Main(string[] args) { ImportModuleUpload test = new ImportModuleUpload(); Console.ReadKey(); } } }
Partager