Mono.Zeroconf – Diff between revs 1 and 2
?pathlinks?
Rev 1 | Rev 2 | |||
---|---|---|---|---|
Line 87... | Line 87... | |||
87 | new_path = Path.Combine(new_path, path_parts[i]); |
87 | new_path = Path.Combine(new_path, path_parts[i]); |
|
88 | } |
88 | } |
|
Line 89... | Line 89... | |||
89 | |
89 | |
|
90 | directories.Add(Path.Combine(new_path, "mono-zeroconf")); |
90 | directories.Add(Path.Combine(new_path, "mono-zeroconf")); |
|
91 | } |
91 | } |
|
- | 92 | |
||
- | 93 | try |
||
92 | |
94 | { |
|
- | 95 | foreach (string directory in directories) |
||
93 | foreach(string directory in directories) { |
96 | { |
|
- | 97 | foreach (string file in Directory.GetFiles(directory, "Mono.Zeroconf.Providers.*.dll")) |
||
94 | foreach(string file in Directory.GetFiles(directory, "Mono.Zeroconf.Providers.*.dll")) { |
98 | { |
|
- | 99 | if (Path.GetFileName(file) != Path.GetFileName(this_asm_path)) |
||
95 | if(Path.GetFileName(file) != Path.GetFileName(this_asm_path)) { |
100 | { |
|
96 | Assembly provider_asm = Assembly.LoadFile(file); |
101 | Assembly provider_asm = Assembly.LoadFile(file); |
|
- | 102 | foreach (Attribute attr in provider_asm.GetCustomAttributes(false)) |
||
97 | foreach(Attribute attr in provider_asm.GetCustomAttributes(false)) { |
103 | { |
|
- | 104 | if (attr is ZeroconfProviderAttribute) |
||
98 | if(attr is ZeroconfProviderAttribute) { |
105 | { |
|
99 | Type type = (attr as ZeroconfProviderAttribute).ProviderType; |
106 | Type type = (attr as ZeroconfProviderAttribute).ProviderType; |
|
- | 107 | IZeroconfProvider provider = (IZeroconfProvider) Activator.CreateInstance(type); |
||
100 | IZeroconfProvider provider = (IZeroconfProvider)Activator.CreateInstance(type); |
108 | try |
|
101 | try { |
109 | { |
|
102 | provider.Initialize(); |
110 | provider.Initialize(); |
|
- | 111 | providers_list.Add(provider); |
||
103 | providers_list.Add(provider); |
112 | } |
|
- | 113 | catch (Exception e) |
||
104 | } catch (Exception e) { |
114 | { |
|
- | 115 | Console.WriteLine(e); |
||
105 | Console.WriteLine (e); |
116 | } |
|
106 | } |
117 | } |
|
107 | } |
118 | } |
|
108 | } |
119 | } |
|
109 | } |
120 | } |
|
110 | } |
121 | } |
|
- | 122 | } |
||
- | 123 | catch |
||
- | 124 | { |
||
- | 125 | // Could not load a provider. |
||
111 | } |
126 | } |
|
112 | |
127 | |
|
113 | if(providers_list.Count == 0) { |
128 | if(providers_list.Count == 0) { |
|
114 | throw new Exception("No Zeroconf providers could be found or initialized. Necessary daemon may not be running."); |
129 | throw new Exception("No Zeroconf providers could be found or initialized. Necessary daemon may not be running."); |
|
Line 115... | Line 130... | |||
115 | } |
130 | } |