c#User3DX Parser我该如何使用它? [英] c# User3DX Parser how can i use it ?

查看:74
本文介绍了c#User3DX Parser我该如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,非常感谢User3DX为我提供代码,以帮助他创建一个单独的线程,告诉我如何使用它这是他提供的代码 

Hello all big thank you for User3DX for supplying me with code to help he asked to create a separate thread on how i would go about using it this is the code he provided 

提供的代码

以及我如何使用它是在我的Windows窗体应用程序中创建一个名为parser的类 

将代码复制到那里 

and how i have used it is creating a class in my windows form application called parser 
copied the code into there 

在我的表单中尊重它通过执行 

reverenced it in my form by doing 

解析器bo3_parser_weapons;

parser bo3_parser_weapons;

然后在按钮点击事件中创建此调用 

then in the button click event created this call 

bo3_parser_weapons = new parser();

bo3_parser_weapons = new parser();

然后我做了 

and then i did 

bo3_parser_weapons.Start()< a href ="https://onedrive.live.com/?authkey=%21AGHleJ9uPbl6Jpk&cid=7E1B2A4F5DF47276&id=7E1B2A4F5DF47276%21129&parId=root&o=OneUp"> 由于使用表格,因此替换了底部的主要功能&NBSP;

bo3_parser_weapons.Start()witch replaces the main function at the bottom due to the fact im using form. 

这一切都很完美,找到的东西我不知道如何使用它或检索信息并在文本框中显示 

it all goes though perfectly fine and find stuff i just not sure how to use it or retrieve information and display it in a text box 

与保存相同它回到文件,但通过调试它确实填充列表并确实保存所有的键/值只是不确定如何restive说displyName ect的值。

same with saving it back to the file but going though the debug it did populate list and did save all the keys/values just not sure how to restive say value of displyName ect.

再次非常感谢你User3DX帮助了我这么多。 

Again big thank you to User3DX for helping me this much. 

推荐答案

你好,

 

 当您想要访问对象时,它很容易通过索引器项目[索引] 。 

 When you want to access the object its easy to via indexer Item[ index ]

下面是根据您的游戏数据文件使用我的Parser类的代码示例

Below is code example of using my Parser Class based on your game data file

结构。请记住,它不是完美的,还有很大的扩展功能空间。

structure. Remember, its not perfect and lots of room for expanding functionality.

 

  代码段

// Declare local scope object for read access only, here is 'gdfEntry'
//
// Below is how manual indexing works
//
// In zero-base indexes, 0 is first element
//
Parser.GDF gdfEntry = bo3_parser_weapons.Items[ 0 ];

// Access Key from Item[ 0 ]
//
string str1 = bo3_parser_weapons.Items[ 0 ].ItemKey;

// Access Value from Item[ 0 ]
//
string str2 = bo3_parser_weapons.Items[ 0 ].ItemValue;

// How to access Item properties
//
string str3 = bo3_parser_weapons.Items[ 0 ].properties[ 0 ].KeyProperty;
string str4 = bo3_parser_weapons.Items[ 0 ].properties[ 0 ].ValueProperty;

// How to change Item properties
//
bo3_parser_weapons.Items[ 0 ].properties[ 0 ] = new Parser.Properties( str3, str4 ); 

// How to change Item
//
bo3_parser_weapons.Items[ 0 ] = new Parser.GDF( str1, str2 );

 如何获取Item元素的数量

 How to get number of Item elements

bo3_parser_weapons.Items.Count

 如何获取Item属性元素的数量

 How to get number of Item property elements

bo3_parser_weapons.Items[ 0 ].properties.Count

 所有Item属性都包含在对象类型 List<> 中,因此您可以获得该类的所有功能。

  All Item properties are contained in object type List<> so you get all the features of the class.

方法 Load()将修剪空白字符串,例如Tabs。因此,在写入文件之前,您可能需要

The method Load() will trim strings of white-space characters, such as Tabs. So, you may want

重新格式化字符串您可以使用
Foreach 循环来枚举项目和项目

to reformat the string before write to file. You can use Foreach loop to Enumerate Item and Item

属性,请参阅下文;

代码段

foreach ( Parser.Properties gdfEntryProp in gdfEntry.properties )
{
    Console.WriteLine( "\tKey {0}\n\tValue {1}\n", gdfEntryProp.KeyProperty, gdfEntryProp.ValueProperty );
}




 如果您对代码有任何疑问或问题,请告知我们。

 


 If you have any question or issues with code then just let me know.

 

 谢谢:)

这篇关于c#User3DX Parser我该如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆