本文整理汇总了C#中ConfigFile类的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile类的具体用法?C# ConfigFile怎么用?C# ConfigFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConfigFile类属于命名空间,在下文中一共展示了ConfigFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PowerNodeBuilding
public PowerNodeBuilding(string configName)
: base(configName)
{
ConfigFile config = new ConfigFile(configName);
m_MaxConnections = config.GetKey_Int("Power", "MaxConnections");
}
示例2: SqliteDbProvider
public SqliteDbProvider(ConfigFile configFile)
{
_connectionString = string.Format("Data Source={0};Version=3", configFile.Get(DbConstants.KEY_FILE_NAME));
_clientExec = configFile.Get(DbConstants.KEY_CLIENT_EXEC);
_dbFileName = configFile.Get(DbConstants.KEY_FILE_NAME);
}
示例3: AddXml
/// <summary>
/// Specify an XML file in S3 to merge with Hadoop's default configuration.
/// </summary>
/// <param name="file">The config file to merge with.</param>
/// <param name="xmlPath">The path in S3 of the XML file.</param>
public void AddXml(ConfigFile file, string xmlPath)
{
string arg = "";
switch (file)
{
case ConfigFile.Site:
arg = "-S";
break;
case ConfigFile.Default:
arg = "-D";
break;
case ConfigFile.Core:
arg = "-C";
break;
case ConfigFile.Hdfs:
arg = "-H";
break;
case ConfigFile.Mapred:
arg = "-M";
break;
}
args.Add(arg);
args.Add(xmlPath);
}
示例4: AddKeyValue
/// <summary>
/// Specify a key-value pair to merge with Hadoop's default configuration.
/// </summary>
/// <param name="file">The config file to merge with.</param>
/// <param name="key">The config key.</param>
/// <param name="value">The config value.</param>
public void AddKeyValue(ConfigFile file, String key, String value)
{
String arg = "";
switch (file)
{
case ConfigFile.Site:
arg = "-s";
break;
case ConfigFile.Default:
arg = "-d"; break;
case ConfigFile.Core:
arg = "-c";
break;
case ConfigFile.Hdfs:
arg = "-h";
break;
case ConfigFile.Mapred:
arg = "-m";
break;
}
args.Add(arg);
args.Add(key + "=" + value);
}
示例5: MySqlDbProvider
public MySqlDbProvider(ConfigFile configFile)
{
if (configFile == null)
{
_connectionString = string.Empty;
return;
}
if (!string.IsNullOrEmpty(configFile.Get(DbConstants.KEY_PWD)))
{
_connectionString = string.Format("SERVER={0};PORT={1};DATABASE={2};UID={3};PWD={4}",
configFile.Get(DbConstants.KEY_HOST),
configFile.Get(DbConstants.KEY_PORT),
configFile.Get(DbConstants.KEY_DATABASE),
configFile.Get(DbConstants.KEY_UID),
configFile.Get(DbConstants.KEY_PWD));
}
else
{
_connectionString = string.Format("SERVER={0};PORT={1};DATABASE={2};UID={3}",
configFile.Get(DbConstants.KEY_HOST),
configFile.Get(DbConstants.KEY_PORT),
configFile.Get(DbConstants.KEY_DATABASE),
configFile.Get(DbConstants.KEY_UID));
}
_uid = configFile.Get(DbConstants.KEY_UID);
_pwd = configFile.Get(DbConstants.KEY_PWD);
_database = configFile.Get(DbConstants.KEY_DATABASE);
_host = configFile.Get(DbConstants.KEY_HOST);
_clientExec = configFile.Get(DbConstants.KEY_CLIENT_EXEC);
_port = configFile.Get(DbConstants.KEY_PORT);
}
示例6: ReadWheelsFromFiles
/// <summary>
/// Go through our media/wheels/ directory and find all of the wheel definitions we have, then make dictionaries out of them
/// and add them to our one big dictionary.
/// </summary>
public void ReadWheelsFromFiles()
{
// since we can run this whenever (like when we're tweaking files), we want to clear our dictionary first
wheels.Clear();
// get all of the filenames of the files in media/wheels/
IEnumerable<string> files = Directory.EnumerateFiles("media/vehicles/", "*.wheel", SearchOption.AllDirectories);
foreach (string filename in files) {
// I forgot ogre had this functionality already built in
ConfigFile cfile = new ConfigFile();
cfile.Load(filename, "=", true);
// each .wheel file can have multiple [sections]. We'll use each section name as the wheel name
ConfigFile.SectionIterator sectionIterator = cfile.GetSectionIterator();
while (sectionIterator.MoveNext()) {
string wheelname = sectionIterator.CurrentKey;
// make a dictionary
var wheeldict = new Dictionary<string, float>();
// go over every property in the file and add it to the dictionary, parsing it as a float
foreach (KeyValuePair<string, string> pair in sectionIterator.Current) {
wheeldict.Add(pair.Key, float.Parse(pair.Value, culture));
}
wheels[wheelname] = wheeldict;
}
cfile.Dispose();
sectionIterator.Dispose();
}
}
示例7: ReadConfigFile
public static ConfigFile ReadConfigFile(string path)
{
ConfigFile file = new ConfigFile();
XmlDocument doc = new XmlDocument();
doc.Load(path);
if (doc.DocumentElement != null)
{
try
{
XmlNode node = doc.DocumentElement.SelectSingleNode("appSettings");
file.Email = node.ChildNodes[0].Attributes[VALUE].Value;
file.User = node.ChildNodes[1].Attributes[VALUE].Value;
file.Password = node.ChildNodes[2].Attributes[VALUE].Value;
file.Sender = node.ChildNodes[3].Attributes[VALUE].Value;
file.SmtpServer = node.ChildNodes[4].Attributes[VALUE].Value;
file.SmtpPort = node.ChildNodes[5].Attributes[VALUE].Value;
file.Delay = node.ChildNodes[6].Attributes[VALUE].Value;
file.ConnString = node.ChildNodes[7].Attributes[VALUE].Value;
}
catch (Exception)
{ }
}
return file;
}
示例8: ReadFromConfig
public void ReadFromConfig(ConfigFile config)
{
this.name = config.Get("Emulation.DeviceName", this.name.ToString());
string str1 = config.Get("Emulation.OSCategory", this.os.ToString());
string str2 = config.Get("Emulation.InputCategory", this.input.ToString());
string str3 = config.Get("Emulation.ScreenCategory", this.screen.ToString());
string str4 = config.Get("Emulation.ScreenDensityCategory", this.screenDensity.ToString());
Log.ConfigFile.Print("Reading Emulated Device: " + this.name + " from " + config.GetPath());
try
{
this.os = (OSCategory) Enum.Parse(typeof (OSCategory), str1);
this.input = (InputCategory) Enum.Parse(typeof (InputCategory), str2);
this.screen = (ScreenCategory) Enum.Parse(typeof (ScreenCategory), str3);
this.screenDensity = (ScreenDensityCategory) Enum.Parse(typeof (ScreenDensityCategory), str4);
}
catch (ArgumentException ex)
{
string format = "Could not parse {0} in {1} as a valid device!";
object[] objArray = new object[2];
int index1 = 0;
string str5 = this.name;
objArray[index1] = (object) str5;
int index2 = 1;
string path = config.GetPath();
objArray[index2] = (object) path;
// Blizzard.Log.Warning(format, objArray);
}
}
示例9: WithKeyValue
/// <summary>
/// Specify a key-value pair to merge with Hadoop's default configuration.
/// </summary>
/// <param name="file">The config file to merge with.</param>
/// <param name="key">The config key.</param>
/// <param name="value">The config value.</param>
/// <returns>A reference to this updated object so that method calls can be chained together.</returns>
public ConfigureHadoop WithKeyValue(ConfigFile file, String key, String value)
{
String arg = "";
switch (file)
{
case ConfigFile.Site:
arg = "-s";
break;
case ConfigFile.Default:
arg = "-d"; break;
case ConfigFile.Core:
arg = "-c";
break;
case ConfigFile.Hdfs:
arg = "-h";
break;
case ConfigFile.Mapred:
arg = "-m";
break;
}
args.Add(arg);
args.Add(key + "=" + value);
return this;
}
示例10: AddParameterDialog
/// <summary>Create <see cref="AddParameterDialog"/>.</summary>
/// <param name="environment">Application environment.</param>
/// <param name="configFile">Config file to use.</param>
public AddParameterDialog(IWorkingEnvironment environment, ConfigFile configFile)
: this(environment)
{
Verify.Argument.IsFalse(configFile != ConfigFile.System && configFile != ConfigFile.User, "configFile");
_configFile = configFile;
}
示例11: Read
public static ConfigFile Read(string path)
{
if (String.IsNullOrWhiteSpace(path))
{
TShock.Log.ConsoleError("CTRS-Config: Invalid filepath given. Starting default configuration...");
return new ConfigFile();
}
Directory.CreateDirectory(Path.GetDirectoryName(path));
try
{
ConfigFile file = new ConfigFile();
if (File.Exists(path))
{
file = JsonConvert.DeserializeObject<ConfigFile>(File.ReadAllText(path));
}
File.WriteAllText(path, JsonConvert.SerializeObject(file, Formatting.Indented));
return file;
}
catch (Exception e)
{
TShock.Log.ConsoleError("CTRS-Config: " + e.Message);
TShock.Log.Error(e.ToString());
return new ConfigFile();
}
}
示例12: ConfigParameter
/// <summary>Create <see cref="ConfigParameter"/>.</summary>
/// <param name="repository">Related <see cref="Repository"/>.</param>
/// <param name="name">Paramater name.</param>
/// <param name="value">Parameter value.</param>
internal ConfigParameter(IConfigAccessor configAccessor, ConfigFile configFile, string name, string value)
: base(name)
{
Verify.Argument.IsNotNull(configAccessor, "configAccessor");
_configAccessor = configAccessor;
_configFile = configFile;
_value = value;
}
示例13: SetGlobalDiffToolToConfig
public static void SetGlobalDiffToolToConfig(ConfigFile configFile, string diffTool)
{
if (GitCommandHelpers.VersionInUse.GuiDiffToolExist)
{
configFile.SetValue("diff.guitool", diffTool);
return;
}
configFile.SetValue("diff.tool", diffTool);
}
示例14: CommandCenterBuilding
public CommandCenterBuilding(string configName)
: base(configName)
{
ConfigFile config = new ConfigFile(configName);
m_MaxPower = config.GetKey_Float("Power", "MaxEnergy");
m_IsPowered = true;
}
示例15: ShipyardBuilding
public ShipyardBuilding(string configName)
: base(configName)
{
ConfigFile configFile = new ConfigFile(configName);
m_ShipCapacity = configFile.GetKey_Int("Shipyard", "ShipCapacity");
m_BuildCoolDown = configFile.GetKey_Float("Shipyard", "BuildCoolDown");
m_ShipConfig = configFile.GetKey_String("Shipyard", "ShipConfig");
}