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


C# System.ConfigNode类代码示例

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


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

示例1: Load

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

            if (configNode.HasValue("passengerName"))
            {
                LoggingUtil.LogWarning(this, "The passengerName and gender attributes are obsolete since Contract Configurator 1.9.0, use kerbal instead.");
                valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "passengerName", x => passengerName = x, this, new List<string>());
                valid &= ConfigNodeUtil.ParseValue<ProtoCrewMember.Gender>(configNode, "gender", x => gender = x, this, Kerbal.RandomGender());
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "experienceTrait", x => experienceTrait = x, this, Kerbal.RandomExperienceTrait());

                legacy = true;
            }
            else
            {
                valid &= ConfigNodeUtil.ParseValue<List<Kerbal>>(configNode, "kerbal", x => kerbals = x, this, new List<Kerbal>());
                legacy = false;
            }

            valid &= ConfigNodeUtil.ParseValue<int>(configNode, "count", x => count = x, this, 1, x => Validation.GE(x, 1));
            valid &= ConfigNodeUtil.ParseValue<ProtoCrewMember.KerbalType>(configNode, "kerbalType", x => kerbalType = x, this, ProtoCrewMember.KerbalType.Tourist);

            return valid;
        }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:25,代码来源:SpawnPassengersFactory.cs

示例2: MappedVariable

        public MappedVariable(ConfigNode node, RasterPropMonitorComputer rpmComp)
        {
            if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange"))
            {
                throw new ArgumentException("MappedVariable missing required values");
            }

            string sourceVariableStr = node.GetValue("sourceVariable");
            string sourceRange = node.GetValue("sourceRange");
            string[] sources = sourceRange.Split(',');
            if (sources.Length != 2)
            {
                throw new ArgumentException("MappedVariable sourceRange does not have exactly two values");
            }

            sourceVariable = new VariableOrNumberRange(rpmComp, sourceVariableStr, sources[0], sources[1]);

            mappedVariable = node.GetValue("mappedVariable");
            string[] destinations = node.GetValue("mappedRange").Split(',');
            if (destinations.Length != 2)
            {
                throw new ArgumentException("MappedVariable mappedRange does not have exactly two values");
            }
            mappedExtent1 = rpmComp.InstantiateVariableOrNumber(destinations[0]);
            mappedExtent2 = rpmComp.InstantiateVariableOrNumber(destinations[1]);
        }
开发者ID:Kerbas-ad-astra,项目名称:RasterPropMonitor,代码行数:26,代码来源:MappedVariable.cs

示例3: ScriptV1

        public ScriptV1()
        {
            exception_raised = false;

             tool = new ExternalApp();
             files_to_glue = new List<FileName>();
             replace_list = new Dictionary<string, string>();
             tools_blocks = new Dictionary<string, ConfigNode>();
             practices_block = null;

             tool_fillmatrix_info = null;
             tool_interpolate_info = null;
             tool_glue_info = null;
             tool_jointimeseries_info = null;

             meteo_block = null;
             meteo_sources_blocks = null;
             meteo_file_name = null;
             meteo_backup_files = false;
             meteo_store_path = null;
             meteo_backup_interpolated_files = false;
             meteo_store_int_path = null;
             meteo_interpolation_path = null;
             meteo_max_contiguous_skips = 8;
             meteo_task = false;
             tool_glue = new HDFGlue();

             standard_names = true;
        }
开发者ID:JauchOnGitHub,项目名称:csharptoolbox,代码行数:29,代码来源:Script.v1.cs

示例4: OnRedecorateModule

        public override void OnRedecorateModule(ConfigNode templateNode, bool payForRedecoration)
        {
            Log("OnRedecorateModule called");

            //Load the modules
            loadModulesFromTemplate(templateNode);
        }
开发者ID:ozraven,项目名称:WildBlueTools,代码行数:7,代码来源:WBIModuleSwitcher.cs

示例5: Save

 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (GetType ().Name);
     clsNode.AddNode (node);
     clsNode.Save (filePath);
 }
开发者ID:602p,项目名称:krpc,代码行数:10,代码来源:ConfigurationStorage.cs

示例6: ChuteTemplate

 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute = pChute;
     this.id = id;
     this.templateGUI = new TemplateGUI(this);
     if (node != null) { Load(node); }
 }
开发者ID:pcwilcox,项目名称:RealChute,代码行数:13,代码来源:ChuteTemplate.cs

示例7: Load

        public void Load(ConfigNode node)
        {
            unlocked = false;

            node.TryGetValue("name", ref name);

            double cost = 0d;
            node.TryGetValue("cost", ref cost);

            node.TryGetValue("entryCost", ref entryCost);
            if(double.IsNaN(entryCost))
                entryCost = Math.Max(0d, cost * RFSettings.Instance.configEntryCostMultiplier);

            node.TryGetValue("sciEntryCost", ref sciEntryCost);
            if(double.IsNaN(sciEntryCost))
                sciEntryCost = Math.Max(0d, cost * RFSettings.Instance.configScienceCostMultiplier);

            node.TryGetValue("unlocked", ref unlocked);

            node.TryGetValue("techRequired", ref techRequired);

            if (node.HasNode("entryCostMultipliers"))
                LoadMultipliers(node.GetNode("entryCostMultipliers"));

            if (node.HasNode("entryCostSubtractors"))
                LoadSubtractors(node.GetNode("entryCostSubtractors"));

            node.TryGetValue("maxSubtraction", ref maxSubtraction);
        }
开发者ID:Kerbas-ad-astra,项目名称:ModularFuelSystem,代码行数:29,代码来源:EngineConfigUpgrade.cs

示例8: GetValueDefault

 public static string GetValueDefault(ConfigNode node, string name, string vale)
 {
     if (node.HasValue(name))
         vale = (node.GetValue(name));
     //else Debug.Log("*MCEPC key not found: " + name);
     return vale;
 }
开发者ID:jwvanderbeck,项目名称:KSPMissionController,代码行数:7,代码来源:Tools.cs

示例9: OnParameterLoad

 protected override void OnParameterLoad(ConfigNode node)
 {
     duration = Convert.ToDouble(node.GetValue("duration"));
     endTime = Convert.ToDouble(node.GetValue("endTime"));
     timerType = ConfigNodeUtil.ParseValue<TimerType>(node, "timerType", TimerType.CONTRACT_ACCEPTANCE);
     parameter = ConfigNodeUtil.ParseValue<string>(node, "parameter", "");
 }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:7,代码来源:Timer.cs

示例10: OnSave

 protected sealed override void OnSave(ConfigNode node)
 {
     try
     {
         if (Root != null)
         {
             node.AddValue("ContractIdentifier", Root.ToString());
         }
         node.AddValue("title", title ?? "");
         node.AddValue("notes", notes ?? "");
         node.AddValue("completedMessage", completedMessage ?? "");
         if (completeInSequence)
         {
             node.AddValue("completeInSequence", completeInSequence);
         }
         if (hidden)
         {
             node.AddValue("hidden", hidden);
         }
         if (hideChildren)
         {
             node.AddValue("hideChildren", hideChildren);
         }
         if (fakeFailures)
         {
             node.AddValue("fakeFailures", fakeFailures);
         }
         OnParameterSave(node);
     }
     catch (Exception e)
     {
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_SAVE, e, Root.ToString(), ID);
     }
 }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:35,代码来源:ContractConfiguratorParameter.cs

示例11: 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

示例12: OnLoad

        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            ConfigNode[] efficiencyNodes = node.GetNodes(kEfficiencyData);
            ConfigNode[] toolTipsShown = node.GetNodes(kToolTip);
            string value = node.GetValue("reputationIndex");

            if (string.IsNullOrEmpty(value) == false)
                reputationIndex = int.Parse(value);

            foreach (ConfigNode efficiencyNode in efficiencyNodes)
            {
                EfficiencyData efficiencyData = new EfficiencyData();
                efficiencyData.Load(efficiencyNode);
                efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
            }

            foreach (ConfigNode toolTipNode in toolTipsShown)
            {
                if (toolTipNode.HasValue("name") == false)
                    continue;
                value = toolTipNode.GetValue("name");

                if (toolTips.ContainsKey(value))
                    toolTips[value] = toolTipNode;
                else
                    toolTips.Add(value, toolTipNode);
            }
        }
开发者ID:PalverZ,项目名称:Pathfinder,代码行数:29,代码来源:WBIPathfinderScenario.cs

示例13: OnSave

        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);
            node.AddValue("selectedObject", selectedObject.ToString());

            node.AddValue("showGui", showGui.ToString());
        }
开发者ID:ozraven,项目名称:WildBlueTools,代码行数:7,代码来源:WBIMeshHelper.cs

示例14: OnLoadFromConfig

        protected override void OnLoadFromConfig(ConfigNode node)
        {
            base.OnLoadFromConfig(node);

            rewardFunds = ConfigNodeUtil.ParseValue<double>(node, "rewardFunds");
            explorationType = ConfigNodeUtil.ParseValue<ExplorationType>(node, "explorationType");
        }
开发者ID:jrossignol,项目名称:Strategia,代码行数:7,代码来源:ExplorationFundingEffect.cs

示例15: ToConfigNode

        public static ConfigNode ToConfigNode(this HarddiskFile file, string nodeName)
        {
            var node = new ConfigNode(nodeName);
            node.AddValue(FilenameValueString, file.Name);

            FileContent content = file.ReadAll();

            if (content.Category == FileCategory.KSM)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else if (content.Category == FileCategory.BINARY)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else
            {
                if (SafeHouse.Config.UseCompressedPersistence)
                {
                    node.AddValue("binary", EncodeBase64(content.String));
                }
                else
                {
                    node.AddValue("ascii", PersistenceUtilities.EncodeLine(content.String));
                }
            }
            return node;
        }
开发者ID:KSP-KOS,项目名称:KOS,代码行数:28,代码来源:PersistenceExtensions.cs


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