コード例 #1
0
 public void Consume(DCSBIOSControl dcsbiosControl)
 {
     _controlId          = dcsbiosControl.identifier;
     _controlDescription = dcsbiosControl.description;
     _controlType        = dcsbiosControl.physical_variant;
     try
     {
         foreach (var dcsbiosControlInput in dcsbiosControl.inputs)
         {
             var inputObject = new DCSBIOSInputObject();
             inputObject.Consume(_controlId, dcsbiosControlInput);
             _dcsbiosInputObjects.Add(inputObject);
         }
     }
     catch (Exception)
     {
         throw new Exception("Failed to copy control " + _controlId + ". Control input is missing." + Environment.NewLine);
     }
 }
コード例 #2
0
        public void ImportString(string str)
        {
            //DCSBIOSInput{AAP_EGIPWR|FIXED_STEP|INC}
            //DCSBIOSInput{AAP_EGIPWR|SET_STATE|65535}
            //DCSBIOSInput{AAP_EGIPWR|ACTION|TOGGLE}
            var value = str;

            if (string.IsNullOrEmpty(str))
            {
                throw new Exception("DCSBIOSInput cannot import null string.");
            }
            if (!str.StartsWith("DCSBIOSInput{") || !str.EndsWith("}"))
            {
                throw new Exception("DCSBIOSInput cannot import string : " + str);
            }
            value = value.Substring(value.IndexOf("{", StringComparison.InvariantCulture) + 1);
            //AAP_EGIPWR|FIXED_STEP|INC}
            //AAP_EGIPWR|SET_STATE|65535}
            //AAP_EGIPWR|ACTION|TOGGLE}
            value = value.Substring(0, value.Length - 1);
            //AAP_EGIPWR|FIXED_STEP|INC
            //AAP_EGIPWR|SET_STATE|65535
            //AAP_EGIPWR|ACTION|TOGGLE
            var entries = value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

            _controlId = entries[0];
            var dcsBIOSControl = DCSBIOSControlLocator.GetControl(_controlId);

            Consume(dcsBIOSControl);

            switch (entries[1])
            {
            case "FIXED_STEP":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.FIXED_STEP)
                    {
                        dcsbiosInputObject.SpecifiedFixedStepArgument = (DCSBIOSFixedStepInput)Enum.Parse(typeof(DCSBIOSFixedStepInput), entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "SET_STATE":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.SET_STATE)
                    {
                        dcsbiosInputObject.SpecifiedSetStateArgument = uint.Parse(entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "ACTION":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.ACTION)
                    {
                        dcsbiosInputObject.SpecifiedActionArgument = entries[2];
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }

            case "VARIABLE_STEP":
            {
                foreach (var dcsbiosInputObject in _dcsbiosInputObjects)
                {
                    if (dcsbiosInputObject.Interface == DCSBIOSInputType.VARIABLE_STEP)
                    {
                        dcsbiosInputObject.SpecifiedVariableStepArgument = int.Parse(entries[2]);
                        _selectedDCSBIOSInput = dcsbiosInputObject;
                        break;
                    }
                }
                break;
            }
            }
        }