-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCapabilities.cs
More file actions
47 lines (41 loc) · 1.71 KB
/
Capabilities.cs
File metadata and controls
47 lines (41 loc) · 1.71 KB
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
using System;
using System.Linq;
using System.Reflection;
namespace EcmaResearchTool
{
internal static class ManagementAgentCapabilities
{
internal static void Get(Type type, Assembly library)
{
var interfaceName = "IMAExtensible2GetCapabilitiesEx";
if (!type.GetInterfaces().Any(t => t.Name == interfaceName))
return;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine($"{type.FullName} implements {interfaceName}!");
Console.ResetColor();
var managementAgent = Activator.CreateInstance(type);
if (managementAgent == null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Couldn't create an instance that inherits type {interfaceName}");
Console.ResetColor();
return;
}
// would need passing in config params, so not sure on initial value during discovery phase
//var capabilitiesMethodName = "GetCapabilitiesEx";
//Console.WriteLine($"Invoking {capabilitiesMethodName}...");
// get the MACapabilities object from the MA
var propertyName = "Capabilities";
var capabilityProperty = managementAgent.GetType().GetProperty(propertyName);
if (capabilityProperty == null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Couldn't get property't {propertyName}");
Console.ResetColor();
return;
}
object capabilities = capabilityProperty.GetValue(managementAgent);
var x = 1;
}
}
}