Beispiel #1
0
        public IHttpAction Execute(string str)
        {
            try
            {
                Request    = new Request(str);
                Parameters = GetParameters();

                Controller = ControllerRegistry.Get(Request.Uri.Controller);

                try
                {
                    ControllerMethod = GetControllerMethod();
                }
                catch (Exception)
                {
                    return(new MethodNotAllowed());
                }

                if (ControllerMethod.GetParameters().Length > 0 && Request.Body.Length > 0)
                {
                    var serializer = SerializerRegistry.Get(Request.GetField("Content-Type"));
                    var bodyType   = ControllerMethod.GetParameters().Last().ParameterType;
                    Parameters[Parameters.Count - 1] = serializer.Deserialize((string)Parameters[Parameters.Count - 1], bodyType);
                }

                return((IHttpAction)ControllerMethod.Invoke(Controller, Request.Parameters));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(new BadRequest());
            }
        }
 internal static void Initialize()
 {
     ledControllers = new Dictionary<byte, ConstructorInfo>();
     foreach (Type type in GetSubtypesInNamespace(Assembly.GetExecutingAssembly(), "CorsairLinkPlusPlus.Driver.CorsairLink.Controller.LED"))
     {
         ILEDController tempInstance = ConstructObjectForInspection(type);
         ledControllers.Add(tempInstance.GetLEDModernControllerID(), type.GetConstructor(new Type[0]));
         ControllerRegistry.Get(tempInstance.Name, type);
     }
 }
Beispiel #3
0
        public override void Call()
        {
            IController controller = ControllerRegistry.Get(GetRequiredArgument <string>("Controller")).New();

            //Set thermistors
            if (controller is ITemperatureDependantController)
            {
                ((ITemperatureDependantController)controller).SetThermistor((IThermistor)RootDevice.FindDeviceByPath(GetRequiredArgument <string>("Thermistor")));
            }

            //Set fixed values
            if (controller is IFixedNumberController)
            {
                ((IFixedNumberController)controller).Value = GetRequiredArgument <double>("Value");
            }

            if (controller is IFixedColorController)
            {
                ((IFixedColorController)controller).Value = GetRequiredArgument <Color>("Value");
            }

            if (controller is IFixedColorCycleController)
            {
                ((IFixedColorCycleController)controller).Value = new List <Color>(GetRequiredArgument <IEnumerable <Color> >("Value")).ToArray();
            }

            //Set curves
            if (controller is ICurveColorController)
            {
                ((ICurveColorController)controller).Value = GetRequiredArgument <ControlCurve <double, Color> >("Value");
            }

            if (controller is ICurveNumberController)
            {
                ((ICurveNumberController)controller).Value = GetRequiredArgument <ControlCurve <double, double> >("Value");
            }

            ((IControllableSensor)Device).Controller = controller;
        }