markus / ConvertService / ServiceBase / PlugInTest / Program.cs @ d33ef543
이력 | 보기 | 이력해설 | 다운로드 (2.88 KB)
1 | c8183702 | taeseongkim | using Markus.Service.Convert.Plugin; |
---|---|---|---|
2 | using Markus.Service.Extensions; |
||
3 | using Markus.Service.Helper; |
||
4 | using System; |
||
5 | using System.Collections.Generic; |
||
6 | using System.Linq; |
||
7 | using System.Text; |
||
8 | using System.Threading.Tasks; |
||
9 | |||
10 | namespace PlugInTest |
||
11 | { |
||
12 | class Program |
||
13 | { |
||
14 | static void Main(string[] args) |
||
15 | { |
||
16 | string ConfigFileName = "Plugin.ini"; |
||
17 | string BasePath = "Plugin"; |
||
18 | |||
19 | Console.WriteLine("PlugIn Load............"); |
||
20 | Console.Write("테스트용 Convert Doc ID : "); |
||
21 | var convertID = Console.ReadLine(); |
||
22 | |||
23 | try |
||
24 | { |
||
25 | TestDocumentInfo.DocumentInfoProcess documentInfoProcess = new TestDocumentInfo.DocumentInfoProcess(); |
||
26 | |||
27 | var pluginPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, BasePath); |
||
28 | var plugins = GenericPluginLoader<IPlugin>.LoadPlugins(pluginPath); |
||
29 | var config = ConfigHelper.AppConfig(ConfigFileName); |
||
30 | |||
31 | Console.Write("Plugin Path : " + pluginPath); |
||
32 | |||
33 | if (plugins != null) |
||
34 | { |
||
35 | Console.WriteLine(""); |
||
36 | Console.WriteLine(""); |
||
37 | Console.Write("Plugin Count : " + plugins.Count()); |
||
38 | |||
39 | foreach (var item in plugins) |
||
40 | { |
||
41 | Dictionary<string, object> parameters = new Dictionary<string, object>(); |
||
42 | |||
43 | var sections = config.Sections.Where(x => x.SectionName == item.Name); |
||
44 | |||
45 | if (sections.Count() > 0) |
||
46 | { |
||
47 | foreach (var param in sections.First().Keys) |
||
48 | { |
||
49 | parameters.Add(param.Name, param.Content); |
||
50 | |||
51 | Console.WriteLine($"Parameter [{param.Name}] : [{param.Content}]"); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | Console.WriteLine(""); |
||
56 | Console.WriteLine(""); |
||
57 | Console.WriteLine("Plugin Type : " + item.Name); |
||
58 | |||
59 | if (item.Name == documentInfoProcess.Name) |
||
60 | { |
||
61 | Console.Write("Call : " + item.Name); |
||
62 | |||
63 | ((Markus.Service.Convert.Plugin.IPlugin)documentInfoProcess).Do(convertID, parameters); |
||
64 | } |
||
65 | |||
66 | Console.WriteLine(""); |
||
67 | Console.WriteLine(""); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | Console.WriteLine("Call Plug In"); |
||
72 | } |
||
73 | catch (Exception ex) |
||
74 | { |
||
75 | Console.WriteLine(ex.ToString()); |
||
76 | |||
77 | if (ex.InnerException != null) |
||
78 | { |
||
79 | Console.WriteLine(ex.InnerException.ToString()); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | Console.ReadLine(); |
||
84 | } |
||
85 | } |
||
86 | } |