本文整理汇总了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);
}
}
示例2: OnSave
public override void OnSave(ConfigNode node)
{
PluginConfiguration config = PluginConfiguration.CreateForType<AntennaPrototype>();
config.SetValue("Window Position", windowPosition);
config.save();
}
示例3: saveText
public void saveText(ConfigNode node)
{
saveMonoOverlay(node);
node.AddValue("text", _text);
node.AddValue("fontName", _fontName);
node.AddValue("fontSize", _fontSize);
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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;
}
}
}
}
示例9: OnLoad
protected override void OnLoad(ConfigNode node)
{
if (node.HasValue("FIELD"))
{
matchFields.AddRange(node.GetValues("FIELD"));
}
}
示例10: OnSave
public override void OnSave(ConfigNode node)
{
PluginConfiguration config = PluginConfiguration.CreateForType<PluginTutorial>();
config.SetValue("Window Position", _windowPosition);
config.save();
}
示例11: saveMonoOverlay
protected void saveMonoOverlay(ConfigNode node)
{
saveOverlay(node);
node.AddValue("red", _red);
node.AddValue("green", _green);
node.AddValue("blue", _blue);
}
示例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");
}
示例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);
}
示例14: OnLoad
public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
//deprecated config conversion//
ModuleConfig = node.HasValue("base_mass")? node : null;
//****************************//
}
示例15: Save
public void Save(ConfigNode node)
{
ConfigNode newNode = new ConfigNode("Resource");
newNode.AddValue("name", resource.name);
newNode.AddValue("ratio", ratio);
node.AddNode(newNode);
}