Esempio n. 1
0
        public static void DevicePropertySet(object deviceInstace, string propertyName, MethodCallParametersList parameters)
        {
            Type deviceType = deviceInstace.GetType();
            PropertyInfo property = deviceType.GetProperty(propertyName);

            try
            {
                object propertyValue = GetParameterValue(parameters.Parameters[0]);

                property.SetValue(deviceInstace, propertyValue, null);
            }
            catch (TargetInvocationException tex)
            {
                throw tex.InnerException;
            }
        }
Esempio n. 2
0
        public static object MakeDeviceMethodCall(object deviceInstace, string methodName, MethodCallParametersList parameters)
        {
            // NOTE: This could work by pure reflection including some safe checks, etc

            Type deviceType = deviceInstace.GetType();
            MethodInfo method = deviceType.GetMethod(methodName);

            var paramList = new List<object>();

            foreach (MethodParameter param in parameters.Parameters)
            {
                paramList.Add(GetParameterValue(param));
            }

            try
            {
                return method.Invoke(deviceInstace, paramList.ToArray());
            }
            catch (TargetInvocationException tex)
            {
                throw tex.InnerException;
            }
        }