当前位置: 首页>>代码示例>>C#>>正文


C# ConfigNode.TryGetValue方法代码示例

本文整理汇总了C#中ConfigNode.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.TryGetValue方法的具体用法?C# ConfigNode.TryGetValue怎么用?C# ConfigNode.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigNode的用法示例。


在下文中一共展示了ConfigNode.TryGetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RealChuteSettings

        /// <summary>
        /// Loads the RealChute_Settings config to memory
        /// </summary>
        public RealChuteSettings()
        {
            ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
            Debug.Log("[RealChute]: Loading settings file.");
            if (!File.Exists(RCUtils.settingsURL))
            {
                Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
                settings.AddValue("autoArm", autoArm);
                settings.AddValue("jokeActivated", jokeActivated);
                settings.AddValue("hideIcon", hideIcon);
                node.AddNode(settings);
                node.Save(RCUtils.settingsURL);
            }
            else
            {
                node = ConfigNode.Load(RCUtils.settingsURL);
                if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { goto missing; }
                if (!settings.TryGetValue("autoArm", ref _autoArm)) { goto missing; }
                if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { goto missing; }
                if (settings.TryGetValue("hideIcon", ref _hideIcon)) { goto missing; }
                return;

                missing:
                {
                    Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
                    settings.ClearValues();
                    settings.AddValue("autoArm", autoArm);
                    settings.AddValue("jokeActivated", jokeActivated);
                    settings.AddValue("hideIcon", hideIcon);
                    node.ClearData();
                    node.AddNode(settings);
                    node.Save(RCUtils.settingsURL);
                }
            }
        }
开发者ID:kevin-ye,项目名称:RealChute,代码行数:38,代码来源:RealChuteSettings.cs

示例2: MaterialDefinition

 /// <summary>
 /// Creates a material definition from a config node
 /// </summary>
 /// <param name="node">Node to initiate the material from</param>
 public MaterialDefinition(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     node.TryGetValue("description", ref _description);
     node.TryGetValue("areaDensity", ref _areaDensity);
     node.TryGetValue("dragCoefficient", ref _dragCoefficient);
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:11,代码来源:MaterialDefinition.cs

示例3: RealChuteSettings

 /// <summary>
 /// Loads the RealChute_Settings config to memory
 /// </summary>
 public RealChuteSettings()
 {
     ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
     Debug.Log("[RealChute]: Loading settings file.");
     if (!System.IO.File.Exists(RCUtils.settingsURL))
     {
         Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Creating new version.");
         settings.AddValue("autoArm", autoArm);
         settings.AddValue("jokeActivated", jokeActivated);
         node.AddNode(settings);
         node.Save(RCUtils.settingsURL);
     }
     else
     {
         node = ConfigNode.Load(RCUtils.settingsURL);
         node.TryGetNode("REALCHUTE_SETTINGS", ref settings);
         bool missing = false;
         if (!settings.TryGetValue("autoArm", ref _autoArm)) { missing = true; }
         if (!settings.TryGetValue("jokeActivated", ref _jokeActivated)) { missing = true; }
         if (missing)
         {
             Debug.LogWarning("[RealChute]: RealChute_Settings.cfg is missing component. Fixing settings file.");
             settings.ClearValues();
             settings.AddValue("autoArm", autoArm);
             settings.AddValue("jokeActivated", jokeActivated);
             node.ClearData();
             node.AddNode(settings);
             node.Save(RCUtils.settingsURL);
         }
     }
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:34,代码来源:RealChuteSettings.cs

示例4: RealChuteSettings

 /// <summary>
 /// Loads the RealChute_Settings config to memory
 /// </summary>
 public RealChuteSettings()
 {
     ConfigNode node = new ConfigNode(), settings = new ConfigNode("REALCHUTE_SETTINGS");
     Debug.Log("[RealChute]: Loading settings file.");
     if (!File.Exists(RCUtils.settingsURL))
     {
         Debug.LogError("[RealChute]: RealChute_Settings.cfg is missing. Creating new.");
         settings.AddValue("autoArm", this._autoArm);
         settings.AddValue("jokeActivated", this._jokeActivated);
         settings.AddValue("guiResizeUpdates", this._guiResizeUpdates);
         settings.AddValue("mustBeEngineer", this._mustBeEngineer);
         settings.AddValue("engineerLevel", this._engineerLevel);
         node.AddNode(settings);
         node.Save(RCUtils.settingsURL);
     }
     else
     {
         node = ConfigNode.Load(RCUtils.settingsURL);
         bool mustSave = false;
         if (!node.TryGetNode("REALCHUTE_SETTINGS", ref settings)) { SaveSettings(); return; }
         if (!settings.TryGetValue("autoArm", ref this._autoArm)) { mustSave = true; return; }
         if (!settings.TryGetValue("jokeActivated", ref this._jokeActivated)) { mustSave = true; return; }
         if (!settings.TryGetValue("guiResizeUpdates", ref this._guiResizeUpdates)) { mustSave = true; return; }
         if (!settings.TryGetValue("mustBeEngineer", ref this._mustBeEngineer)) { mustSave = true; return; }
         if (!settings.TryGetValue("engineerLevel", ref this._engineerLevel)) { mustSave = true; return; }
         this._presets = settings.GetNodes("PRESET");
         if (mustSave) { SaveSettings(); }
     }
 }
开发者ID:pcwilcox,项目名称:RealChute,代码行数:32,代码来源:RealChuteSettings.cs

示例5: ModelConfig

 /// <summary>
 /// Creates a ModelConfig from the given ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to get the values from</param>
 public ModelConfig(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     node.TryGetValue("diameter", ref _diameter);
     node.TryGetValue("count", ref _count);
     node.TryGetValue("maxDiam", ref _maxDiam);
     _parameters = new List<ModelParameters>(node.GetNodes("PARAMETERS").Select(n => new ModelParameters(n)));
 }
开发者ID:pcwilcox,项目名称:RealChute,代码行数:12,代码来源:ModelConfig.cs

示例6: ModelConfig

 /// <summary>
 /// Creates a ModelConfig from the given ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to get the values from</param>
 public ModelConfig(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     node.TryGetValue("diameter", ref _diameter);
     node.TryGetValue("count", ref _count);
     node.TryGetValue("maxDiam", ref _maxDiam);
     ConfigNode chute = new ConfigNode();
     if (node.TryGetNode("MAIN", ref chute)) { _main = new ModelParameters(chute); }
     if (node.TryGetNode("SECONDARY", ref chute)) { _secondary = new ModelParameters(chute); }
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:14,代码来源:ModelConfig.cs

示例7: ResourceInfo

 public ResourceInfo(ConfigNode node)
 {
     node.TryGetValue("name", ref this.name);
     resource = PartResourceLibrary.Instance.GetDefinition(this.Name);
     node.TryGetValue("realName", ref this.realName);
     node.TryGetValue("colour", ref this.colour);
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:7,代码来源:ResourceInfoLibrary.cs

示例8: TextureConfig

 /// <summary>
 /// Initiates all the texture and model nodes in this model config
 /// </summary>
 public TextureConfig(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     _cases = node.GetNodes("CASE_TEXTURE").Select(n => new CaseConfig(n)).ToDictionary(c => c, c => c.name);
     _canopies = node.GetNodes("CANOPY_TEXTURE").Select(n => new CanopyConfig(n)).ToDictionary(c => c, c => c.name);
     _models = node.GetNodes("CANOPY_MODEL").Select(n => new ModelConfig(n)).ToDictionary(m => m, m => m.name);
 }
开发者ID:kevin-ye,项目名称:RealChute,代码行数:10,代码来源:TextureConfig.cs

示例9: TextureConfig

        /// <summary>
        /// Initiates all the texture and model nodes in this model config
        /// </summary>
        public TextureConfig(ConfigNode node)
        {
            node.TryGetValue("name", ref _name);
            foreach(ConfigNode cfg in node.nodes)
            {
                if (cfg.name == "CASE_TEXTURE")
                {
                    CaseConfig parachuteCase = new CaseConfig(cfg);
                    _cases.Add(parachuteCase);
                    continue;
                }

                if (cfg.name == "CANOPY_TEXTURE")
                {
                    CanopyConfig canopy = new CanopyConfig(cfg);
                    _canopies.Add(canopy);
                    continue;
                }

                if (cfg.name == "CANOPY_MODEL")
                {
                    ModelConfig model = new ModelConfig(cfg);
                    _models.Add(model);
                    continue;
                }
            }
            if (_cases.Count > 0) { _caseNames = _cases.Select(c => c.name).ToArray(); }
            if (_canopies.Count > 0) { _canopyNames = _canopies.Select(c => c.name).ToArray(); }
            if (_models.Count > 0) { _modelNames = _models.Select(m => m.name).ToArray(); }
        }
开发者ID:vosechu,项目名称:RealChute,代码行数:33,代码来源:TextureConfig.cs

示例10: MaterialDefinition

 /// <summary>
 /// Creates a material definition from a config node
 /// </summary>
 /// <param name="node">Node to initiate the material from</param>
 public MaterialDefinition(ConfigNode node)
 {
     node.TryGetValue("name", ref this._name);
     node.TryGetValue("description", ref this._description);
     node.TryGetValue("areaDensity", ref this._areaDensity);
     node.TryGetValue("dragCoefficient", ref this._dragCoefficient);
     node.TryGetValue("areaCost", ref this._areaCost);
     node.TryGetValue("maxTemp", ref this._maxTemp);
     node.TryGetValue("specificHeat", ref this._specificHeat);
     node.TryGetValue("emissivity", ref this._emissivity);
 }
开发者ID:pcwilcox,项目名称:RealChute,代码行数:15,代码来源:MaterialDefinition.cs

示例11: SizeNode

 /// <summary>
 /// Creates a new SizeNode from the given ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to create the object from</param>
 public SizeNode(ConfigNode node)
 {
     node.TryGetValue("size", ref _size);
     node.TryGetValue("sizeID", ref _sizeID);
     node.TryGetValue("caseMass", ref _caseMass);
     node.TryGetValue("topNode", ref _topNode);
     node.TryGetValue("topNodeSize", ref _topNodeSize);
     node.TryGetValue("bottomNode", ref _bottomNode);
     node.TryGetValue("bottomNodeSize", ref _bottomNodeSize);
     node.TryGetValue("cost", ref _cost);
 }
开发者ID:kevin-ye,项目名称:RealChute,代码行数:15,代码来源:SizeNode.cs

示例12: DataBody

 public DataBody(ConfigNode body, string type)
 {
     this.name = body.name;
     this.type = type;
     if (!body.TryGetValue("currentError", ref currentError))
     {
         currentError = 1d;
         body.AddValue("currentError", currentError.ToString("0.00000"));
     }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:10,代码来源:DataBody.cs

示例13: Load

        internal static VesselInfo Load(ConfigNode node)
        {
            string vesselName = "Unknown";
            node.TryGetValue("vesselName", ref vesselName);
            double lastUpdate = 0f;
            node.TryGetValue("lastUpdate", ref lastUpdate);
            //string vesselName = Utilities.GetNodeValue(node, "vesselName", "Unknown");
            //double lastUpdate = Utilities.GetNodeValue(node, "lastUpdate", 0.0);

            VesselInfo info = new VesselInfo(vesselName, lastUpdate);
            node.TryGetValue("numSeats", ref info.numSeats);
            node.TryGetValue("numCrew", ref info.numCrew);
            node.TryGetValue("numOccupiedParts", ref info.numOccupiedParts);
            node.TryGetValue("numFrznCrew", ref info.numFrznCrew);
            node.TryGetValue("hibernating", ref info.hibernating);
            node.TryGetValue("hasextDoor", ref info.hasextDoor);
            node.TryGetValue("hasextPod", ref info.hasextPod);
            node.TryGetValue("storedEC", ref info.storedEC);
            node.TryGetValue("predictedECOut", ref info.predictedECOut);

            info.vesselType = Utilities.GetNodeValue(node, "vesselType", VesselType.Unknown);

            return info;
        }
开发者ID:Kerbas-ad-astra,项目名称:DeepFreeze,代码行数:24,代码来源:VesselInfo.cs

示例14: Preset

 /// <summary>
 /// Creates a new Preset from the given ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to create the object from</param>
 public Preset(ConfigNode node)
 {
     node.TryGetValue("name", ref _name);
     node.TryGetValue("description", ref _description);
     node.TryGetValue("textureLibrary", ref _textureLibrary);
     node.TryGetValue("sizeID", ref _sizeID);
     node.TryGetValue("cutSpeed", ref _cutSpeed);
     node.TryGetValue("timer", ref _timer);
     node.TryGetValue("mustGoDown", ref _mustGoDown);
     node.TryGetValue("deployOnGround", ref _deployOnGround);
     node.TryGetValue("spares", ref _spares);
     node.TryGetValue("caseName", ref _caseName);
     node.TryGetValue("bodyName", ref _bodyName);
     if (node.HasNode("MAIN")) { _main = new ChuteParameters(node.GetNode("MAIN")); }
     if (node.HasNode("SECONDARY")) { _secondary = new ChuteParameters(node.GetNode("SECONDARY")); }
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:20,代码来源:Preset.cs

示例15: ChuteParameters

 /// <summary>
 /// Creates a new ChuteParameters from the ConfigNode
 /// </summary>
 /// <param name="node">ConfigNode to create the object from</param>
 public ChuteParameters(ConfigNode node)
 {
     node.TryGetValue("material", ref _material);
     node.TryGetValue("preDeployedDiameter", ref _preDeployedDiameter);
     node.TryGetValue("deployedDiameter", ref _deployedDiameter);
     node.TryGetValue("minIsPressure", ref _minIsPressure);
     node.TryGetValue("minDeployment", ref _minDeployment);
     node.TryGetValue("minPressure", ref _minPressure);
     node.TryGetValue("deploymentAlt", ref _deploymentAlt);
     node.TryGetValue("cutAlt", ref _cutAlt);
     node.TryGetValue("preDeploymentSpeed", ref _preDeploymentSpeed);
     node.TryGetValue("deploymentSpeed", ref _deploymentSpeed);
     node.TryGetValue("chuteTexture", ref _chuteTexture);
     node.TryGetValue("modelName", ref _modelName);
     node.TryGetValue("type", ref _type);
     node.TryGetValue("calcSelect", ref _calcSelect);
     node.TryGetValue("getMass", ref _getMass);
     node.TryGetValue("useDry", ref _useDry);
     node.TryGetValue("mass", ref _mass);
     node.TryGetValue("landingSpeed", ref _landingSpeed);
     node.TryGetValue("deceleration", ref _deceleration);
     node.TryGetValue("refDepAlt", ref _refDepAlt);
     node.TryGetValue("chuteCount", ref _chuteCount);
 }
开发者ID:vosechu,项目名称:RealChute,代码行数:28,代码来源:Preset.cs


注:本文中的ConfigNode.TryGetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。