當前位置: 首頁>>代碼示例>>C#>>正文


C# ConfigNode.GetValues方法代碼示例

本文整理匯總了C#中System.ConfigNode.GetValues方法的典型用法代碼示例。如果您正苦於以下問題:C# ConfigNode.GetValues方法的具體用法?C# ConfigNode.GetValues怎麽用?C# ConfigNode.GetValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ConfigNode的用法示例。


在下文中一共展示了ConfigNode.GetValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Load

        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<List<VesselIdentifier>>(configNode, "vessel", x => vessels = x, this, new List<VesselIdentifier>());
            valid &= ConfigNodeUtil.ParseValue<VesselIdentifier>(configNode, "defineDockedVessel", x => defineDockedVessel = x, this, (VesselIdentifier)null);

            // Validate using the config node instead of the list as it may undergo deferred loading
            if (parent is VesselParameterGroupFactory)
            {
                if (configNode.GetValues("vessel").Count() > 1)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": When used under a VesselParameterGroup, no more than one vessel may be specified for the Docking parameter.");
                    valid = false;
                }
            }
            else
            {
                if (configNode.GetValues("vessel").Count() == 0)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": Need at least one vessel specified for the Docking parameter.");
                    valid = false;
                }
                if (configNode.GetValues("vessel").Count() > 2)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": Cannot specify more than two vessels for the Docking parameter.");
                    valid = false;
                }
            }

            return valid;
        }
開發者ID:linuxgurugamer,項目名稱:ContractConfigurator,代碼行數:33,代碼來源:DockingFactory.cs

示例2: OnLoad

        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            //Load all the drill info
            drillResources = node.GetValues("drillResource");
        }
開發者ID:PalverZ,項目名稱:Pathfinder,代碼行數:7,代碼來源:WBIDrillSwitcher.cs

示例3: VariableHandler

            public VariableHandler(ConfigNode node, RasterPropMonitorComputer ourComp)
            {
                handlerName = node.GetValue("name");
                foreach (string variableRecord in node.GetValues("variable")) {
                    var record = new VariableRecord();
                    string[] tokens = variableRecord.Split(',');
                    if (tokens.Length >= 2) {
                        double defaultDouble;
                        if (double.TryParse(tokens[1], out defaultDouble)) {
                            record.defaultValue = defaultDouble;
                        } else {
                            if (tokens[1].Trim() == "fallback") {
                                record.fallback = true;
                            } else {
                                record.defaultString = tokens[1];
                            }
                        }
                    }
                    if (tokens.Length >= 3) {
                        record.cacheable = bool.Parse(tokens[2]);
                    }
                    handledVariables.Add(tokens[0], record);
                }

                active = InstantiateHandler(node, ourComp, out handlerFunction);
            }
開發者ID:hansjurgen,項目名稱:RasterPropMonitor,代碼行數:26,代碼來源:VariableHandler.cs

示例4: Load

        public void Load(ConfigNode node)
        {
            if (!HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || parent.vessel == null) {
                return;
            }

            string[] values = node.GetValues("node");
            int max = values.Length;
            for (int k = 0; k < max; k++) {
                string[] info = values[k].Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
                Vector3d deltav = new Vector3d();
                double d = 0.0;

                if (info.Length == 4) {
                    double.TryParse(info[0], out d);
                    deltav.x = d;

                    d = 0.0;
                    double.TryParse(info[1], out d);
                    deltav.y = d;

                    d = 0.0;
                    double.TryParse(info[2], out d);
                    deltav.z = d;

                    d = 0.0;
                    double.TryParse(info[3], out d);

                    // at the very least it'll /act/ like a proper maneuver node.
                    nodes.Add(new NodeState(deltav, d));
                }
            }
            Debug.Log("Node Saver loaded " + max + " nodes.");
        }
開發者ID:pellinor0,項目名稱:ksp-precisenode,代碼行數:34,代碼來源:NodeList.cs

示例5: Harddisk

        public Harddisk(ConfigNode node)
        {
            Capacity = 10000;

            foreach (string s in node.GetValues("capacity"))
            {
                Capacity = Int32.Parse(s);
            }

            foreach (string s in node.GetValues("volumeName"))
            {
                Name = s;
            }

            foreach (var fileNode in node.GetNodes("file"))
            {
                Files.Add(new File(fileNode));
            }
        }
開發者ID:jwvanderbeck,項目名稱:KOS_old,代碼行數:19,代碼來源:Harddisk.cs

示例6: EngineMount

 public EngineMount(ConfigNode node)
 {
     name = node.GetStringValue("name");
     layoutNames = node.GetValues("layoutName");
     defaultDiameter = node.GetFloatValue("size", defaultDiameter);
     minDiameter = node.GetFloatValue("minSize", minDiameter);
     maxDiameter = node.GetFloatValue("maxSize", maxDiameter);
     engineSpacing = node.GetFloatValue("engineSpacing", engineSpacing);
     canAdjustSize = node.GetBoolValue("canAdjustSize", canAdjustSize);
     rotateEngineModels = node.GetBoolValues("rotateEngines");
     mountDefinition = SSTUEngineMountDefinition.getMountDefinition(name);
 }
開發者ID:SixDasher,項目名稱:SSTULabs,代碼行數:12,代碼來源:EngineMount.cs

示例7: MathVariable

        internal MathVariable(ConfigNode node)
        {
            name = node.GetValue("name");

            string[] sources = node.GetValues("sourceVariable");
            for (int i = 0; i < sources.Length; ++i)
            {
                VariableOrNumber sv = VariableOrNumber.Instantiate(sources[i]);
                sourceVariables.Add(sv);
            }

            if (sourceVariables.Count == 0)
            {
                throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name);
            }

            string oper = node.GetValue("operator");
            if (oper == Operator.NONE.ToString())
            {
                op = Operator.NONE;
            }
            else if (oper == Operator.ADD.ToString())
            {
                op = Operator.ADD;
            }
            else if (oper == Operator.SUBTRACT.ToString())
            {
                op = Operator.SUBTRACT;
            }
            else if (oper == Operator.MULTIPLY.ToString())
            {
                op = Operator.MULTIPLY;
            }
            else if (oper == Operator.DIVIDE.ToString())
            {
                op = Operator.DIVIDE;
            }
            else if (oper == Operator.MAX.ToString())
            {
                op = Operator.MAX;
            }
            else if (oper == Operator.MIN.ToString())
            {
                op = Operator.MIN;
            }
            else
            {
                throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper);
            }
        }
開發者ID:ndevenish,項目名稱:RasterPropMonitor,代碼行數:50,代碼來源:MathVariable.cs

示例8: VariableHandler

            public VariableHandler(ConfigNode node, Part ourPart)
            {
                handlerName = node.GetValue("name");
                foreach (string variableRecord in node.GetValues("variable"))
                {
                    var record = new VariableRecord();
                    string[] tokens = variableRecord.Split(',');
                    if (tokens.Length >= 2)
                    {
                        double defaultDouble;
                        if (double.TryParse(tokens[1], NumberStyles.Any, CultureInfo.InvariantCulture, out defaultDouble))
                        {
                            record.defaultValue = defaultDouble;
                        }
                        else
                        {
                            if (tokens[1].Trim() == "fallback")
                            {
                                record.fallback = true;
                            }
                            else
                            {
                                record.defaultValue = tokens[1];
                                //record.defaultString = tokens[1];
                            }
                        }
                    }
                    if (tokens.Length >= 3)
                    {
                        record.cacheable = bool.Parse(tokens[2]);
                    }
                    handledVariables.Add(tokens[0], record);
                }

                active = InstantiateHandler(node, ourPart, out handlerFunction);
            }
開發者ID:Kerbas-ad-astra,項目名稱:RasterPropMonitor,代碼行數:36,代碼來源:VariableHandler.cs

示例9: LoadFromNode

        public override void LoadFromNode(ConfigNode node)
        {
            base.LoadFromNode(node);

            var values = node.GetValues(ConfigName);

            if (values.Length == 0) return;

            CreateListIfNecessary();

            bool createNewItems = false;
            if (Count != values.Length)
            {
                ClearList();
                createNewItems = true;
            }

            for (int i = 0; i < values.Length; i++)
            {
                object obj = null;

                if (!createNewItems)
                    obj = List[i];

                CFGUtil.AssignConfigObject(this, values[i], ref obj);

                if (createNewItems)
                    List.Add(obj);
                else
                    List[i] = obj; // This may be self-assignment under certain circumstances
            }
        }
開發者ID:blowfishpro,項目名稱:B9PartSwitch,代碼行數:32,代碼來源:ConfigField.cs

示例10: ParseCurve

        public static AnimationCurve ParseCurve(ConfigNode node)
        {
            var values = node.GetValues("key");

            int length = (int)values.Length;
            var curve = new AnimationCurve();
            for (int i = 0; i < length; i++)
            {
                string[] strArrays = values[i].Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
                curve.AddKey(float.Parse(strArrays[0]), float.Parse(strArrays[1]));
            }
            return (curve);
        }
開發者ID:jesusHERCULESchrist,項目名稱:PlanetFactory,代碼行數:13,代碼來源:PlanetFactory.cs

示例11: loadCrew

        private Notes_Archived_Crew_Container loadCrew(ConfigNode node)
        {
            Notes_Archived_Crew_Container c = new Notes_Archived_Crew_Container();

            for (int i = 0; i < node.GetValues("KERBAL").Length; i++)
            {
                string k = node.GetValues("KERBAL")[i];

                if (string.IsNullOrEmpty(k))
                    continue;

                if (HighLogic.CurrentGame.CrewRoster == null)
                    break;

                ProtoCrewMember p = HighLogic.CurrentGame.CrewRoster[k];

                if (p == null)
                    continue;

                c.addCrewObject(p);
            }

            return c;
        }
開發者ID:DMagic1,項目名稱:KSP_Vessel_Manager,代碼行數:24,代碼來源:Notes_Scenario.cs

示例12: ReadCurve

        // Readers
        List<double[]> ReadCurve(FloatCurve curve)
        {
            ConfigNode config = new ConfigNode();
            List<double[]> list = new List<double[]>();
            NumericCollectionParser<double> value = new NumericCollectionParser<double>();

            curve.Save(config);

            foreach (string k in config.GetValues("key"))
            {
                value.SetFromString(k);
                list.Add(value.value.ToArray());
            }

            return list;
        }
開發者ID:Sigma88,項目名稱:Sigma-Dimensions,代碼行數:17,代碼來源:AtmosphereTopLayer.cs

示例13: InsertValue

 private static void InsertValue(ConfigNode newNode, int index, string name, string value)
 {
     string[] oldValues = newNode.GetValues(name);
     if (index < oldValues.Length)
     {
         newNode.RemoveValues(name);
         int i = 0;
         for (; i < index; ++i)
             newNode.AddValue(name, oldValues[i]);
         newNode.AddValue(name, value);
         for (; i < oldValues.Length; ++i)
             newNode.AddValue(name, oldValues[i]);
         return;
     }
     newNode.AddValue(name, value);
 }
開發者ID:Kerbas-ad-astra,項目名稱:ModuleManager,代碼行數:16,代碼來源:moduleManager.cs

示例14: OnLoad

        public override void OnLoad(ConfigNode node)
        {
            if (!compatible) {
                return;
            }

            if (MFSSettings.tankDefinitions == null) {
                MFSSettings.Initialize ();
            }

            // Load the volume. If totalVolume is specified, use that to calc the volume
            // otherwise scale up the provided volume. No KSPField support for doubles
            if (node.HasValue ("totalVolume") && double.TryParse (node.GetValue ("totalVolume"), out totalVolume)) {
                ChangeTotalVolume (totalVolume);
            } else if (node.HasValue ("volume") && double.TryParse (node.GetValue ("volume"), out volume)) {
                totalVolume = volume * 100d / utilization;
            }
            if (isDatabaseLoad) {
                MFSSettings.SaveOverrideList(part, node.GetNodes("TANK"));
                ParseBaseMass(node);
                ParseBaseCost(node);
                ParseInsulationFactor(node);
                typesAvailable = node.GetValues ("typeAvailable");
                RecordManagedResources ();
            } else if (isEditorOrFlight) {
                // The amounts initialized flag is there so that the tank type loading doesn't
                // try to set up any resources. They'll get loaded directly from the save.
                UpdateTankType (false);
                // Destroy any resources still hanging around from the LOADING phase
                for (int i = part.Resources.Count - 1; i >= 0; --i) {
                    PartResource partResource = part.Resources[i];
                    if (!tankList.Contains (partResource.resourceName))
                        continue;
                    part.Resources.Remove(partResource.info.id);
                }
                RaiseResourceListChanged ();
                // Setup the mass
                massDirty = true;
                CalculateMass();
            }
        }
開發者ID:NathanKell,項目名稱:ModularFuelSystem,代碼行數:41,代碼來源:ModuleFuelTanks.cs

示例15: ModifyCurveKeys

        public static FloatCurve ModifyCurveKeys(FloatCurve initialCurve, float vacMult, float atmMult, bool extendToZero)
        {
            ConfigNode tempNode = new ConfigNode();

            initialCurve.Save(tempNode);

            string[] keyStrings = tempNode.GetValues("key");

            float maxTime, ispAtMaxTime, secondTime, ispAtSecondTime, maxPressure;
            maxTime = ispAtMaxTime = secondTime = ispAtSecondTime = maxPressure = 0;
            FloatCurve newAtmosphereCurve = new FloatCurve();

            maxTime = initialCurve.maxTime;

            for (int i = 0; i < keyStrings.Length; i++)
            {
                string[] splitKey = keyStrings[i].Split(' ');

                float scalar = vacMult + Convert.ToSingle(splitKey[0]) * (atmMult - vacMult);
                if (!extendToZero)
                    scalar = Mathf.Clamp(scalar, Mathf.Min(atmMult, vacMult), Mathf.Max(atmMult, vacMult));

                if (Convert.ToSingle(splitKey[0]) != 0)
                    newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, Convert.ToSingle(splitKey[2]) * scalar, Convert.ToSingle(splitKey[3]) * scalar);
                else
                    newAtmosphereCurve.Add(Convert.ToSingle(splitKey[0]), Convert.ToSingle(splitKey[1]) * scalar, 0, 0);

                if (i == keyStrings.Length - 2)
                {
                    secondTime = Convert.ToSingle(splitKey[0]);
                    ispAtSecondTime = Convert.ToSingle(splitKey[1]) * scalar;
                }
            }

            ispAtMaxTime = newAtmosphereCurve.Evaluate(maxTime);

            if (extendToZero && (ispAtSecondTime - ispAtMaxTime) >= 0.0001f)
            {
                maxPressure = maxTime + (0.01f - ispAtMaxTime) / (ispAtSecondTime - ispAtMaxTime) * (secondTime - maxTime);
                newAtmosphereCurve.Add(maxPressure, 0.01f, 0, 0);
            }

            return newAtmosphereCurve;
        }
開發者ID:stevehead,項目名稱:Kerbal-Isp-Difficulty-Scaler,代碼行數:44,代碼來源:KerbalIspDifficultyScaler.cs


注:本文中的System.ConfigNode.GetValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。