Line | |
---|
1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | |
---|
6 | namespace Com.Piwigo.Uploader.Service |
---|
7 | { |
---|
8 | static class ServiceFactory |
---|
9 | { |
---|
10 | public static IService GetByType<T>() |
---|
11 | { |
---|
12 | IService objICom; |
---|
13 | |
---|
14 | switch (typeof(T).Name) |
---|
15 | { |
---|
16 | case "Connect": |
---|
17 | objICom = aConnect; |
---|
18 | break; |
---|
19 | case "Disconnect": |
---|
20 | objICom = aDisconnect; |
---|
21 | break; |
---|
22 | case "LoadFromDirectory": |
---|
23 | objICom = aLoadFromDirectory; |
---|
24 | break; |
---|
25 | default: |
---|
26 | throw new ArgumentException("ServiceFactory GetByType : IService Type unknow.", "Type"); |
---|
27 | } |
---|
28 | |
---|
29 | return objICom; |
---|
30 | } |
---|
31 | |
---|
32 | private static IService _aConnect; |
---|
33 | private static IService aConnect |
---|
34 | { |
---|
35 | get |
---|
36 | { |
---|
37 | if (_aConnect == null) |
---|
38 | { |
---|
39 | _aConnect = new Connect(); |
---|
40 | } |
---|
41 | return _aConnect; |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | private static IService _aDisconnect; |
---|
46 | private static IService aDisconnect |
---|
47 | { |
---|
48 | get |
---|
49 | { |
---|
50 | if (_aDisconnect == null) |
---|
51 | { |
---|
52 | _aDisconnect = new Disconnect(); |
---|
53 | } |
---|
54 | return _aDisconnect; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | private static IService _aLoadFromDirectory; |
---|
59 | private static IService aLoadFromDirectory |
---|
60 | { |
---|
61 | get |
---|
62 | { |
---|
63 | if (_aLoadFromDirectory == null) |
---|
64 | { |
---|
65 | _aLoadFromDirectory = new LoadFromDirectory(); |
---|
66 | } |
---|
67 | return _aLoadFromDirectory; |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.