/// <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()); }
IniParser.Model.IniData getIniParserConfigInjectionTextures() { IniParser.Model.IniData parsedIniData = null; // Attempt to load configInjectionTextures.ini string userIniPathConfigInjectionTextures = Path.Combine(Application.dataPath, iniPathConfigInjectionTextures); if (File.Exists(userIniPathConfigInjectionTextures)) { parsedIniData = iniParser.ReadFile(userIniPathConfigInjectionTextures); } // Load fallback configInjectionTextures .ini TextAsset asset = Resources.Load <TextAsset>(iniPathFallbackConfigInjectionTextures); if (asset != null) { MemoryStream stream = new MemoryStream(asset.bytes); StreamReader reader = new StreamReader(stream); parsedIniData = iniParser.ReadData(reader); reader.Close(); } return(parsedIniData); }
/// <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; }
/// <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 (); }