本文整理汇总了C#中IniParser.FileIniDataParser.ReadData方法的典型用法代码示例。如果您正苦于以下问题:C# FileIniDataParser.ReadData方法的具体用法?C# FileIniDataParser.ReadData怎么用?C# FileIniDataParser.ReadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IniParser.FileIniDataParser
的用法示例。
在下文中一共展示了FileIniDataParser.ReadData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Config
/// <summary>
/// Reads the configuration settings from disk
/// </summary>
/// <returns>The configuration settings for Pattern Lab</returns>
public IniData Config()
{
// Return cached value if set
if (_config != null) return _config;
// Configure the INI parser to handler the comments in the Pattern Lab config file
var parser = new FileIniDataParser();
parser.Parser.Configuration.AllowKeysWithoutSection = true;
parser.Parser.Configuration.SkipInvalidLines = true;
var path = Path.Combine(HttpRuntime.AppDomainAppPath, FilePathConfig);
if (!File.Exists(path))
{
// If the config doesn't exist create a new version
var virtualPath = string.Format("~/{0}", FilePathConfig);
var defaultConfig = new EmbeddedResource(string.Format("{0}.default", virtualPath));
var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Builder.CreateFile(virtualPath, defaultConfig.ReadAllText().Replace("$version$", version), null,
new DirectoryInfo(HttpRuntime.AppDomainAppPath));
}
// Read the contents of the config file into a read-only stream
using (
var stream = new FileStream(path, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite))
{
_config = parser.ReadData(new StreamReader(stream));
}
return _config;
}
示例2: ParseBoards
/// <summary>
/// Parses the boards.
/// </summary>
/// <returns>The boards.</returns>
/// <param name="Path">Path.</param>
public static Board[] ParseBoards(StreamReader Path)
{
var Parser = new IniParser.FileIniDataParser ();
IniData Data = Parser.ReadData (Path);
var Boards = new System.Collections.Generic.List<Board> ();
foreach (SectionData sd in Data.Sections) {
try {
Boards.Add (new Board () {
Name = sd.Keys.GetKeyData ("Name").Value,
NumberOfAnalogPins = Convert.ToUInt32 (sd.Keys.GetKeyData ("NumberOfAnalogPins").Value),
NumberOfDigitalPins = Convert.ToUInt32 (sd.Keys.GetKeyData ("NumberOfDigitalPins").Value),
MCU = sd.Keys.GetKeyData ("MCU").Value,
ImageFilePath = sd.Keys.GetKeyData ("ImagePath").Value,
SDA = ConfigHelper.StringToArray (sd.Keys.GetKeyData ("SDA").Value),
SCL = ConfigHelper.StringToArray (sd.Keys.GetKeyData ("SCL").Value),
RX = ConfigHelper.StringToArray (sd.Keys.GetKeyData ("RX").Value),
TX = ConfigHelper.StringToArray (sd.Keys.GetKeyData ("TX").Value),
UseDTR = Convert.ToBoolean (sd.Keys.GetKeyData ("DTR").Value),
HardwareAnalogPins = ConfigHelper.StringToArray (sd.Keys.GetKeyData ("HWAPinsAddrs").Value),
AnalogReferences = ConfigHelper.StringToARefDict (sd.Keys.GetKeyData ("AREF").Value),
PinLayout = ConfigHelper.StringToLayout (sd.Keys.GetKeyData ("PinLeft").Value, sd.Keys.GetKeyData ("PinRight").Value, sd.Keys.GetKeyData ("PinBottom").Value),
PinLocation = ConfigHelper.StringToPinPlacement (sd.Keys.GetKeyData ("PinPosition").Value)
});
} catch (Exception ex) {
Console.WriteLine (ex);
}
}
return Boards.ToArray ();
}