当前位置: 首页>>代码示例>>C#>>正文


C# FileIniDataParser.ReadData方法代码示例

本文整理汇总了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;
        }
开发者ID:fhchina,项目名称:patternlab-net,代码行数:36,代码来源:PatternProvider.cs

示例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 ();
        }
开发者ID:Onkeliroh,项目名称:DSA,代码行数:35,代码来源:ConfigurationManager.cs


注:本文中的IniParser.FileIniDataParser.ReadData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。