本文整理汇总了C#中IniParser.FileIniDataParser类的典型用法代码示例。如果您正苦于以下问题:C# FileIniDataParser类的具体用法?C# FileIniDataParser怎么用?C# FileIniDataParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileIniDataParser类属于IniParser命名空间,在下文中一共展示了FileIniDataParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileConfigurationStore
public FileConfigurationStore(IList<string> filePaths)
{
if (filePaths == null ||
filePaths.Count == 0 ||
!filePaths.All(c => !String.IsNullOrWhiteSpace(c)))
throw new ArgumentNullException("filePaths", "The parameter filePaths cannot be empty or contains empty string");
this.fileIniDataParser = new FileIniDataParser();
this.fileIniDataParser.Parser.Configuration.CommentString = "#";
this.filePaths = filePaths;
}
示例2: GetConnectionString
public static String GetConnectionString(String AppID)
{
FileIniDataParser i = new FileIniDataParser();
i.Parser.Configuration.CommentString = "#";
IniData data = i.ReadFile(Settings.Preferences.GetConfig());
bool decrypt = false;
if (Convert.ToBoolean(data["HOST"]["Encrypt"]))
{
decrypt = true;
}
String myConnectionString = "";
if (decrypt)
{
myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};",
data["HOST"]["IP"], data["HOST"]["User"], MySQLSet.Decrypt(data["HOST"]["Pass"]), data["HOST"]["Port"], data["DS"][AppID]);
}
else
{
myConnectionString = String.Format("server={0};uid={1}; pwd={2}; port={3}; database={4};",
data["HOST"]["IP"], data["HOST"]["User"], data["HOST"]["Pass"], data["HOST"]["Port"], data["DS"][AppID]);
}
return myConnectionString;
}
示例3: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
if (!File.Exists("DefaultService.ini") || !File.Exists("service.ini")
|| !File.Exists("version.dat") || !File.Exists("bin/BlackDesert32.exe")
|| !File.Exists("bin64/BlackDesert64.exe")
)
{
MessageBox.Show(@"Invalid Launcher location.", @"Error!");
Application.Exit();
return;
}
var parser = new FileIniDataParser();
var data = parser.ReadFile("DefaultService.ini");
var serverIp1 = data["KR_REAL"]["AUTH_DOMAIN"];
var data2 = parser.ReadFile("service.ini");
var serverIp2 = data2["KR"]["AUTHENTIC_DOMAIN"];
serverIP.Text = serverIp1;
authip.Text = serverIp2;
serverIP.ForeColor = serverIp1 == "auth.black.game.daum.net" ? Color.Green : Color.Red;
authip.ForeColor = serverIp2 == "blackauth.black.game.daum.net" ? Color.Green : Color.Red;
}
示例4: programLoad
public void programLoad()
{
{ //load from config file
FileIniDataParser parser = new FileIniDataParser();
IniData data = parser.ReadFile("resource/installer.ini");
{// set logo image
var logoPath = data["GLOBAL"]["logo"];
string logoClean = String.Format("resource/{0}", logoPath);
Console.WriteLine("ini file claims logo image is {0}", logoClean);
FileInfo fi = new FileInfo(logoClean);
long logoSize = (fi.Length / 1024);
Console.WriteLine("Loaded logo ({0}KB)", logoSize);
this.logo.ImageLocation = logoClean;
fi = null; //destroy FileInfo
}
{//figure out what to install
var toInstall = data["GLOBAL"]["file"];
var where = data["GLOBAL"]["destination"];
Console.WriteLine("ini file claims {0} is going to be installed to {1}", toInstall, where);
}
{//set readme docs
this.readmedocs = new Uri(data["GLOBAL"]["readme"], UriKind.Absolute);
Console.WriteLine("ini file claims readme docs are located {0}", this.readmedocs);
}
{//set start page text
this.startText = data["GLOBAL"]["startpage"].Replace("{break}",Environment.NewLine);
Console.WriteLine("loaded start text from ini file");
}
}
}
示例5: Main
public static void Main()
{
//Create an instance of a ini file parser
FileIniDataParser fileIniData = new FileIniDataParser();
if (File.Exists("NewTestIniFile.ini"))
File.Delete("NewTestIniFile.ini");
//Parse the ini file
IniData parsedData = fileIniData.LoadFile("TestIniFile.ini");
//Write down the contents of the ini file to the console
Console.WriteLine("---- Printing contents of the INI file ----\n");
Console.WriteLine(parsedData.ToString());
//Get concrete data from the ini file
Console.WriteLine("---- Printing contents concrete data from the INI file ----");
Console.WriteLine("setMaxErrors = " + parsedData["GeneralConfiguration"]["setMaxErrors"]);
Console.WriteLine();
//Modify the INI contents and save
Console.WriteLine();
//Write down the contents of the modified ini file to the console
Console.WriteLine("---- Printing contents of the new INI file ----\n");
IniData modifiedParsedData = ModifyINIData(parsedData);
Console.WriteLine(modifiedParsedData.ToString());
//Save to a file
fileIniData.SaveFile("NewTestIniFile.ini", modifiedParsedData);
}
示例6: Train
public static void Train()
{
FileIniDataParser parser = new FileIniDataParser();
IniData data = parser.ReadFile("config.ini");
for (int i = 1; i <= 4; i++)
{
string stringPosition = data["barracks"]["barrack" + i];
Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1]));
string stringTroop = data["troops"]["barrack" + i];
int intTroop = Convert.ToInt32(stringTroop);
if(pointPosition.X != -1 || pointPosition.Y != -1)
{
Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false);
Thread.Sleep(1000);
if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176)))
Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false);
else if(ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("3_3", Settings.xDif, Settings.yDif)), Color.FromArgb(161, 184, 207)))
Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("3_3", Settings.xDif, Settings.yDif), false);
else
Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false);
Thread.Sleep(1000);
while (!SameRGB(Home.bsProcess.image.GetPixelColor(CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif))))
{
Home.bsProcess.mouse.SendClick(WButton.Left, CocFunctions.Buttons.GetPos("troop" + intTroop, Settings.xDif, Settings.yDif), false);
Thread.Sleep(100);
}
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0,0), false);
Thread.Sleep(500);
}
}
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
}
示例7: Load
public static void Load()
{
List.Clear();
foreach (var item in Directory.GetFiles(Global.Folder.Profile, "*.ifp"))
{
var parser = new FileIniDataParser();
IniData data = parser.ReadFile(item);
var p = new Profile();
p.File = item;
p.Info.Format = data["info"]["format"];
p.Info.Platform = data["info"]["platform"];
p.Info.Name = data["info"]["name"];
p.Info.Author = data["info"]["author"];
p.Info.Web = data["info"]["web"];
p.Picture.Resolution = data["picture"]["resolution"];
p.Picture.FrameRate = data["picture"]["framerate"];
p.Picture.BitDepth = Convert.ToInt32(data["picture"]["bitdepth"]);
p.Picture.Chroma = Convert.ToInt32(data["picture"]["chroma"]);
p.Video.Preset = data["video"]["preset"];
p.Video.Tune = data["video"]["tune"];
p.Video.Type = Convert.ToInt32(data["video"]["type"]);
p.Video.Value = data["video"]["value"];
p.Video.Command = data["video"]["cmd"];
p.Audio.Encoder = data["audio"]["encoder"];
p.Audio.BitRate = data["audio"]["bitrate"];
p.Audio.Freq = data["audio"]["frequency"];
p.Audio.Chan = data["audio"]["channel"];
p.Audio.Args = data["audio"]["cmd"];
List.Add(p);
}
}
示例8: WriteConfig
/// <summary>
/// Writes the config data to disk. This method is thread-blocking, and all write operations
/// are synchronized via lock(WriteLock).
/// </summary>
/// <param name="Parser">The parser dealing with the current data.</param>
/// <param name="Data">The data which should be written to file.</param>
private void WriteConfig(FileIniDataParser Parser, IniData Data)
{
lock (WriteLock)
{
Parser.WriteFile (GetConfigPath (), Data);
}
}
示例9: CreateDefault
public static void CreateDefault()
{
//Create ini file
FileIniDataParser parser = new FileIniDataParser();
IniData data = new IniData();
//Add global section
data.Sections.AddSection("game");
//Add global settings
data["game"]["hidemode"] = "1";
//Add collectors section
data.Sections.AddSection("collectors");
//Add collectors locations
for (int i = 1; i <= 17; i++)
{
data["collectors"]["collector" + i] = "-1:-1";
}
//Add troops section
data.Sections.AddSection("troops");
//Add troops settings
for (int i = 1; i <= 4; i++)
{
data["troops"]["barrack" + i] = "0";
}
//Add search section
data.Sections.AddSection("search");
//Add search settings
data["search"]["gold"] = "50000";
data["search"]["elixir"] = "50000";
data["search"]["dark"] = "0";
data["search"]["trophy"] = "0";
data["search"]["bgold"] = "1";
data["search"]["belixir"] = "1";
data["search"]["bdark"] = "0";
data["search"]["btrophy"] = "0";
data["search"]["alert"] = "0";
//Add attack section
data.Sections.AddSection("attack");
//Add attack settings
data["attack"]["topleft"] = "True";
data["attack"]["topright"] = "True";
data["attack"]["bottomleft"] = "True";
data["attack"]["bottomright"] = "True";
data["attack"]["mode"] = "0";
data["attack"]["maxtrophy"] = "1000";
data["attack"]["bmaxtrophy"] = "False";
data["attack"]["deploytime"] = "75";
//Save the file
parser.WriteFile(AppSettings.Cfg.FilePath, data);
}
示例10: Main
static void Main(string[] args)
{
string server_ini_file = @"Ini\servers.ini";
C("HTTP Server Starting");
if (File.Exists(server_ini_file))
{
C("Using File {0} for configuration", server_ini_file);
FileIniDataParser parser = new FileIniDataParser();
var servers = parser.LoadFile(server_ini_file);
servers.Sections
.ToList()
.ForEach(server_config =>
{
NSServer server = new NSServer(server_config.Keys["listenon"], Int32.Parse(server_config.Keys["port"]), "/");
server.CreateHttpServer();
C("Starting Server {0} : listening on http://{1}:{2}/", server_config.SectionName, server_config.Keys["listenon"], server_config.Keys["port"]);
});
C("Servers have been started.");
}
Console.WriteLine("Waiting...");
Console.Read();
}
示例11: getReports
List<Report> getReports()
{
if (reports == null)
{
reports = new List<Report>();
var dir = new DirectoryInfo(GraphPkgInfo.ReportsDir);
foreach (var reportDir in dir.GetDirectories())
{
// parse the ini and create the report object
var parser = new FileIniDataParser();
var infoTxtPath = Path.Combine(reportDir.FullName, "info.txt");
if (File.Exists(infoTxtPath) == false)
continue;
var infoData = parser.LoadFile(infoTxtPath, relaxedIniRead: true);
var report = new Report
{
Key = reportDir.Name,
Name = getInfoData(infoData, "Name"),
Description = getInfoData(infoData, "Description"),
ReportDir = reportDir.FullName
};
report.ThemeFile = getInfoData(infoData, "Theme", report.ThemeFile);
report.TemplateFile = getInfoData(infoData, "Template", report.TemplateFile);
report.ScriptFile = getInfoData(infoData, "Script", report.ScriptFile);
report.TemplateLayoutFile = getInfoData(infoData, "TemplateLayout", report.TemplateLayoutFile);
reports.Add(report);
}
}
return reports;
}
示例12: IsTroopsReady
public static bool IsTroopsReady()
{
FileIniDataParser parser = new FileIniDataParser();
IniData data = parser.ReadFile("config.ini");
string stringPosition = data["barracks"]["barrack1"];
Point pointPosition = new Point(Convert.ToInt32(stringPosition.Split(';')[0]), Convert.ToInt32(stringPosition.Split(';')[1]));
if (pointPosition.X != -1 || pointPosition.Y != -1)
{
Home.bsProcess.mouse.SendClick(WButton.Left, pointPosition, false);
Thread.Sleep(500);
if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("5_5", Settings.xDif, Settings.yDif)), Color.FromArgb(112, 140, 176)))
Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("5_5", Settings.xDif, Settings.yDif), false);
else
Home.bsProcess.mouse.SendClick(WButton.Left, Buttons.GetPos("4_4", Settings.xDif, Settings.yDif), false);
Thread.Sleep(500);
if (ColorDif.isCorrect(Home.bsProcess.image.GetPixelColor(Buttons.GetPos("troop_ready", Settings.xDif, Settings.yDif)), Color.FromArgb(216, 72, 81)))
{
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
Thread.Sleep(500);
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
return true;
}
}
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
Thread.Sleep(500);
Home.bsProcess.mouse.SendClick(WButton.Left, new Point(0, 0), false);
return false;
}
示例13: Main
static void Main(string[] args)
{
Console.WriteLine("Reading Generation Info File \n");
FileIniDataParser parser = new FileIniDataParser();
IniData genData = parser.LoadFile("generation.ini");
Console.WriteLine("Generation Info File Read \n");
foreach (SectionData genSection in genData.Sections)
{
Console.WriteLine(String.Format("Analyzing {0} \n", genSection.SectionName));
Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName));
GenerationInfo info = new GenerationInfo();
info.CompanyName = genSection.Keys["companyname"].Replace(";", "");
info.DataNameSpace = genSection.Keys["datanamespace"].Replace(";", "");
info.FolderPath = genSection.Keys["path"].Replace(";", "");
info.ServerName = genSection.Keys["server"].Replace(";", "");
info.DataBase = genSection.Keys["database"].Replace(";", "");
MGenerator.Tools.Generator.GenerateFromDatabase(info);
Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName));
Console.WriteLine(String.Format("done \n", genSection.SectionName));
Console.WriteLine(String.Format("=============================================== \n", genSection.SectionName));
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
示例14: Issue11_Tests
public void Issue11_Tests()
{
FileIniDataParser parser = new FileIniDataParser();
IniData parsedData = parser.LoadFile("Issue11_example.ini",true);
Assert.That(parsedData.Global[".reg (Win)"], Is.EqualTo("notepad.exe"));
}
示例15: Display
public static void Display()
{
foreach (var item in Directory.GetFiles(Global.Folder.Language, "*.ini"))
{
var data = new FileIniDataParser().ReadFile(item, Encoding.UTF8);
Lists.Add(new Language() { Code = data["info"]["Code"], Name = data["info"]["Name"] });
}
}