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


C# ConfigNode类代码示例

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


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

示例1: ConfigObjectNode

        internal ConfigObjectNode(dynamic n, KeyType key, ConfigNode parent)
            : base(key, parent)
        {
            _children = new Dictionary<string, ConfigNode>();

            var expando = n as IDictionary<string, object>;
            foreach (var kvp in expando)
            {
                ConfigNode valueNode;
                var newKey = new StringKey(kvp.Key);

                if (kvp.Value is ExpandoObject)
                {
                    valueNode = ConfigNodeFactory.CreateConfigObjectNode(kvp.Value, newKey, this);
                }
                else if (kvp.Value is IList<object>)
                {
                    valueNode = ConfigNodeFactory.CreateConfigListNode(kvp.Value, newKey, this);
                }
                else
                {
                    valueNode = ConfigNodeFactory.CreateConfigLeafNode(kvp.Value, newKey, this);
                }

                _children.Add(kvp.Key, valueNode);
            }
        }
开发者ID:yikliu,项目名称:DynamicConfig,代码行数:27,代码来源:ConfigObjectNode.cs

示例2: OnSave

        public override void OnSave(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType<AntennaPrototype>();

            config.SetValue("Window Position", windowPosition);
            config.save();
        }
开发者ID:Skoth,项目名称:KSPCommEngr,代码行数:7,代码来源:RCSPrototype.cs

示例3: saveText

 public void saveText(ConfigNode node)
 {
     saveMonoOverlay(node);
     node.AddValue("text", _text);
     node.AddValue("fontName", _fontName);
     node.AddValue("fontSize", _fontSize);
 }
开发者ID:panteras1000,项目名称:TheWriteStuff,代码行数:7,代码来源:IM_Text.cs

示例4: Load

        public static Layout Load(string name, ConfigNode node)
        {
            try
            {
                var layout = new Layout(name);

                foreach (var child in node.GetNodes())
                {
                    IElement element = Element.Create(child.name);

                    if (element != null)
                    {
                        element.Load(child);
                        layout.AddElement(element);
                    }
                    else
                    {
                        Historian.Print("Failed to load layout element of type '{0}'.", child.name);
                    }
                }

                return layout;
            }
            catch
            {
                Historian.Print("Failed to load layout '{0}'.", name);
            }

            return Empty;
        }
开发者ID:linuxgurugamer,项目名称:Historian,代码行数:30,代码来源:Layout.cs

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

示例6: HandleSettings

    public void HandleSettings()
    {
        if (!File.Exists<KineTechAnimationModuleLoader>(SETTINGS_FILE_NAME))
        {
            ConfigNode node = new ConfigNode();
            node.AddValue("DumpDocumentationOnStartup", false);
            node.Save(IOUtils.GetFilePathFor(typeof(KineTechAnimationModuleLoader), SETTINGS_FILE_NAME));
        }

        if (File.Exists<KineTechAnimationModuleLoader>(SETTINGS_FILE_NAME))
        {
            ConfigNode node = ConfigNode.Load(
                IOUtils.GetFilePathFor(typeof(KineTechAnimationModuleLoader), SETTINGS_FILE_NAME));

            if(node == null)
                return;

            //Dump Documentation
            if(node.HasValue("DumpDocumentationOnStartup"))
            {
                bool working = false;
                if(bool.TryParse(node.GetValue("DumpDocumentationOnStartup"), out working))
                {
                    GameObject dumperObject = new GameObject("Kine-Tech Animation - ConfigDocumentationGenerator");
                    dumperObject.AddComponent<KConfigDocumentationGenerator>();
                    GameObject.DontDestroyOnLoad(dumperObject);
                }
            }

        }
    }
开发者ID:KineMorto,项目名称:KineTechAnimationLibrary,代码行数:31,代码来源:KineTechAnimationModuleLoader.cs

示例7: Configure

        public void Configure(ConfigNode node)
        {
            ConfigNode[] pages = node.GetNodes("PAGE_DEFINITION");

            if (pages != null && pages.Length > 0)
            {
                definitions = new PageDefinition[pages.Length];

                for (int i = 0; i < pages.Length; ++i)
                {
                    string variableName = pages[i].GetValue("variableName");
                    string range = pages[i].GetValue("range");
                    string page = pages[i].GetValue("page");
                    if (string.IsNullOrEmpty(variableName) || string.IsNullOrEmpty(range) || string.IsNullOrEmpty(page))
                    {
                        JUtil.LogErrorMessage(this, "Incorrect page definition for page {0}", i);
                        definitions = null;
                        if (string.IsNullOrEmpty(definitionIn))
                        {
                            // Make sure we aren't crashing later.
                            definitionIn = definitionOut;
                        }
                        return;
                    }
                    definitions[i] = new PageDefinition(variableName, range, page);
                }
            }
        }
开发者ID:ndevenish,项目名称:RasterPropMonitor,代码行数:28,代码来源:JSIVariablePageTextSwitcher.cs

示例8: LoadItems

 internal IEnumerator<YieldInstruction> LoadItems(ConfigNode settings, System.Random random)
 {
     foreach (string type in KRESUtils.types.Values)
     {
         if (KRESUtils.GetRelevantBodies(type).Any(b => b.bodyName == this.Name))
         {
             foreach (ConfigNode data in settings.GetNode(type).GetNode(this.Name).GetNodes("KRES_DATA"))
             {
                 string resourceName = string.Empty;
                 data.TryGetValue("name", ref resourceName);
                 if (!PartResourceLibrary.Instance.resourceDefinitions.Contains(resourceName)) { continue; }
                 if (type == "ore")
                 {
                     string path = Path.Combine(KRESUtils.GetSavePath(), "KRESTextures/" + name + "/" + resourceName + ".png");
                     if (File.Exists(path))
                     {
                         ResourceItem item = new ResourceItem(data, resourceName, this.Name, random);
                         resourceItems.Add(item);
                     }
                 }
                 else if (type == "gas" || type == "liquid")
                 {
                     ResourceItem item = new ResourceItem(data, resourceName, this.Name, type, random);
                     resourceItems.Add(item);
                 }
                 yield return null;
             }
         }
     }
 }
开发者ID:CYBUTEK,项目名称:KRES,代码行数:30,代码来源:ResourceBody.cs

示例9: OnLoad

 protected override void OnLoad(ConfigNode node)
 {
     if (node.HasValue("FIELD"))
     {
         matchFields.AddRange(node.GetValues("FIELD"));
     }
 }
开发者ID:Kerbas-ad-astra,项目名称:TarsierSpaceTechnology,代码行数:7,代码来源:TSTScienceParam.cs

示例10: OnSave

        public override void OnSave(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType<PluginTutorial>();

            config.SetValue("Window Position", _windowPosition);
            config.save();
        }
开发者ID:Kerbal007,项目名称:PluginTutorial,代码行数:7,代码来源:PluginTutorial.cs

示例11: saveMonoOverlay

 protected void saveMonoOverlay(ConfigNode node)
 {
     saveOverlay(node);
     node.AddValue("red", _red);
     node.AddValue("green", _green);
     node.AddValue("blue", _blue);
 }
开发者ID:panteras1000,项目名称:TheWriteStuff,代码行数:7,代码来源:IM_MonoOverlay.cs

示例12: OnLoad

        private GUIStyle _windowStyle, _labelStyle; // Setup Gui Style

        #endregion Fields

        #region Methods

        public override void OnLoad(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType<PluginTutorial>();

            config.load();
            _windowPosition = config.GetValue<Rect>("Window Position");
        }
开发者ID:Kerbal007,项目名称:PluginTutorial,代码行数:13,代码来源:PluginTutorial.cs

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

示例14: OnLoad

 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     //deprecated config conversion//
     ModuleConfig = node.HasValue("base_mass")? node : null;
     //****************************//
 }
开发者ID:pjslauta,项目名称:hangar,代码行数:7,代码来源:Hangar.cs

示例15: Save

 public void Save(ConfigNode node)
 {
     ConfigNode newNode = new ConfigNode("Resource");
     newNode.AddValue("name", resource.name);
     newNode.AddValue("ratio", ratio);
     node.AddNode(newNode);
 }
开发者ID:RichardDastardly,项目名称:pWingsMerged,代码行数:7,代码来源:WingTankResource.cs


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