/*
* WmiSettingsHandler
*
* Copyright 2018 Raising the Floor - US
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Management;
///
/// Static class to hold constants related with WMI API.
///
public static class WMIConstants {
///
/// Dictionary holding a map from the string types to proper C# types to use as
/// return values from WMI set methods.
///
/// The existence of this types is not optional because the method "InvokeMethod" used
/// to call the target class method returns a "object" type. In order to properly
/// recover the inner type, we need to know which is the return type of the calling function.
///
public static readonly Dictionary RetTypes = new Dictionary {
{ "int", typeof(int) },
{ "uint", typeof(uint) },
{ "string", typeof(string) }
};
///
/// If the desired WMI method is too complex for being call using the standard provied interface,
/// or if it's return type can't be mapped to a simple value. Then we should wrap the target
/// WMI function into a simpler interface that can be exposed using the common interface.
///
public static readonly Dictionary> CustomQuerys = new Dictionary> {
};
};
///
/// Provides an entry point to make a generic query updating some WMI setting through edge.js.
///
public class Startup {
public static int ExpectedArgNum = 5;
///
/// Verifies that the input payload has a supported format. The valid input payload formats are:
/// -
///
///
///
public void checkInput(object input) {
if (input == null) {
throw new ArgumentException("Error: Payload was null.");
}
bool invalidFormat = true;
bool notSupportedRetType = true;
bool nonSupportedWrapper = false;
try {
object[] payload = ((IEnumerable