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


C# IO.StringReader类代码示例

本文整理汇总了C#中System.IO.StringReader的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringReader类的具体用法?C# System.IO.StringReader怎么用?C# System.IO.StringReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.IO.StringReader类属于命名空间,在下文中一共展示了System.IO.StringReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: parse

        public List<CCFE_ConfigurationProperty> parse()
        {
            List<CCFE_ConfigurationProperty> propertyList = new List<CCFE_ConfigurationProperty>();

            //read in file data as string
            string fileText = System.IO.File.ReadAllText(FileLocation);

            //create StringReader to parse string
            System.IO.StringReader stringReader = new System.IO.StringReader(fileText);

            string line;
            string propertyPattern = "^([A-Z])([A-z])+=\\S+";
            string[] propertyValues;
            while ((line = stringReader.ReadLine()) != null)
            {
                //check if line is a property using regex
                if (System.Text.RegularExpressions.Regex.IsMatch(line, propertyPattern))
                {
                    //break string into 'name' and 'value' parts
                    propertyValues = line.Split('=');
                    propertyList.Add(new CCFE_ConfigurationProperty(propertyValues[0], propertyValues[1]));
                }
            }
            stringReader.Close();

            return propertyList;
        }
开发者ID:ccfe-capstone,项目名称:ccfe,代码行数:27,代码来源:CCFE_FileHandler.cs

示例2: Parse

        public void Parse()
        {
            if (_IsParsed) return;

            var json = Encoding.UTF8.GetString(this.data);
            using (var strReader = new System.IO.StringReader(json)) {
                using (var r = new JsonTextReader(strReader)) {
                    while (r.Read()) {
                        if (r.TokenType == JsonToken.PropertyName) {
                            switch (r.Value.ToString()) {
                                case "region":
                                    ParseRegions(r);
                                    break;
                                case "nonpop":
                                    _NonPops = r.ReadInt32Array();
                                    break;
                                case "item":
                                    _Items = r.ReadInt32Array();
                                    break;
                                case "instance_contents":
                                    _InstanceContents = r.ReadInt32Array();
                                    break;
                                default:
                                    Console.Error.WriteLine("Unknown 'BNpcName' data key: {0}", r.Value);
                                    throw new NotSupportedException();
                            }
                        }
                    }
                }
            }

            _IsParsed = true;
        }
开发者ID:KevinAllenWiegand,项目名称:SaintCoinach,代码行数:33,代码来源:BNpcName.Parse.cs

示例3: Parse

        public void Parse()
        {
            if (_IsParsed)
                return;

            var json = Encoding.UTF8.GetString(this.data);
            using (var strReader = new System.IO.StringReader(json)) {
                using (var r = new JsonTextReader(strReader)) {
                    while (r.Read()) {
                        if (r.TokenType == JsonToken.PropertyName) {
                            switch (r.Value.ToString()) {
                                case "client_quest":
                                    _AsQuestClient = r.ReadInt32Array();
                                    break;
                                case "coordinate":
                                    ParseCoordinate(r);
                                    break;
                                case "quest":
                                    _Quests = r.ReadInt32Array();
                                    break;
                                case "shop":
                                    ParseShops(r);
                                    break;
                                default:
                                    Console.Error.WriteLine("Unknown 'ENpcResident' data key: {0}", r.Value);
                                    throw new NotSupportedException();
                            }
                        }
                    }
                }
            }

            _IsParsed = true;
        }
开发者ID:viion,项目名称:SaintCoinach,代码行数:34,代码来源:ENpcResident.Parse.cs

示例4: ListQueues

        public List<Queue> ListQueues(
            string prefix = null,
            bool IncludeMetadata = false,
            int timeoutSeconds = 0,
            Guid? xmsclientrequestId = null)
        {
            List<Queue> lQueues = new List<Queue>();
            string strNextMarker = null;
            do
            {
                string sRet = Internal.InternalMethods.ListQueues(UseHTTPS, SharedKey, AccountName, prefix, strNextMarker,
                    IncludeMetadata: IncludeMetadata, timeoutSeconds: timeoutSeconds, xmsclientrequestId: xmsclientrequestId);

                //Microsoft.SqlServer.Server.SqlContext.Pipe.Send("After Internal.InternalMethods.ListQueues = " + sRet);

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                using (System.IO.StringReader sr = new System.IO.StringReader(sRet))
                {
                    doc.Load(sr);
                }

                foreach (System.Xml.XmlNode node in doc.SelectNodes("EnumerationResults/Queues/Queue"))
                {
                    lQueues.Add(Queue.ParseFromXmlNode(this, node));
                };

                strNextMarker = doc.SelectSingleNode("EnumerationResults/NextMarker").InnerText;

                //Microsoft.SqlServer.Server.SqlContext.Pipe.Send("strNextMarker == " + strNextMarker);

            } while (!string.IsNullOrEmpty(strNextMarker));

            return lQueues;
        }
开发者ID:DomG4,项目名称:sqlservertoazure,代码行数:34,代码来源:AzureQueueService.cs

示例5: PhotoInfoParseFull

        public void PhotoInfoParseFull()
        {
            string x = "<photo id=\"7519320006\">"
                    + "<location latitude=\"54.971831\" longitude=\"-1.612683\" accuracy=\"16\" context=\"0\" place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">"
                    + "<neighbourhood place_id=\"Ke8IzXlQV79yxA\" woeid=\"15532\">Central</neighbourhood>"
                    + "<locality place_id=\"DW0IUrFTUrO0FQ\" woeid=\"20928\">Gateshead</locality>"
                    + "<county place_id=\"myqh27pQULzLWcg7Kg\" woeid=\"12602156\">Tyne and Wear</county>"
                    + "<region place_id=\"2eIY2QFTVr_DwWZNLg\" woeid=\"24554868\">England</region>"
                    + "<country place_id=\"cnffEpdTUb5v258BBA\" woeid=\"23424975\">United Kingdom</country>"
                    + "</location>"
                    + "</photo>";

            System.IO.StringReader sr = new System.IO.StringReader(x);
            System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
            xr.Read();

            var info = new PhotoInfo();
            ((IFlickrParsable)info).Load(xr);

            Assert.AreEqual("7519320006", info.PhotoId);
            Assert.IsNotNull(info.Location);
            Assert.AreEqual((GeoAccuracy)16, info.Location.Accuracy);

            Assert.IsNotNull(info.Location.Country);
            Assert.AreEqual("cnffEpdTUb5v258BBA", info.Location.Country.PlaceId);
        }
开发者ID:JamieKitson,项目名称:flickrnet-experimental,代码行数:26,代码来源:PhotosGeoTests.cs

示例6: Deserialize

 public static TransactionSpecification Deserialize(string xml)
 {
     System.IO.StringReader stringReader = new System.IO.StringReader(xml);
     System.Xml.XmlTextReader xmlTextReader = new System.Xml.XmlTextReader(stringReader);
     System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(TransactionSpecification));
     return ((TransactionSpecification)(xmlSerializer.Deserialize(xmlTextReader)));
 }
开发者ID:hitgeek,项目名称:OopFactoryX12Parser,代码行数:7,代码来源:TransactionSpecification.cs

示例7: TestStopList

		public virtual void  TestStopList()
		{
			System.Collections.Hashtable stopWordsSet = new System.Collections.Hashtable();
			stopWordsSet.Add("good", "good");
			stopWordsSet.Add("test", "test");
			stopWordsSet.Add("analyzer", "analyzer");

            // {{Aroush  how can we copy 'stopWordsSet' to 'System.String[]'?
            System.String[] arrStopWordsSet = new System.String[3];
            arrStopWordsSet[0] = "good";
            arrStopWordsSet[1] = "test";
            arrStopWordsSet[2] = "analyzer";
            // Aroush}}

			StopAnalyzer newStop = new StopAnalyzer(arrStopWordsSet);
			System.IO.StringReader reader = new System.IO.StringReader("This is a good test of the english stop analyzer");
			TokenStream stream = newStop.TokenStream("test", reader);
			Assert.IsTrue(stream != null);
			Token token = null;
			try
			{
				while ((token = stream.Next()) != null)
				{
					System.String text = token.TermText();
					Assert.IsTrue(stopWordsSet.Contains(text) == false);
				}
			}
			catch (System.IO.IOException e)
			{
				Assert.IsTrue(false);
			}
		}
开发者ID:runefs,项目名称:Marvin,代码行数:32,代码来源:TestStopAnalyzer.cs

示例8: FromString

 public static Variant FromString(string xml)
 {
     using (var ms = new System.IO.StringReader(xml))
     {
         return Create(ms, XmlMode.Default).Read();
     }
 }
开发者ID:rokstrnisa,项目名称:protean,代码行数:7,代码来源:XmlReader.cs

示例9: Read

        //────────────────────────────────────────
        /// <summary>
        /// Listを作成します。
        /// 
        /// セルのデータ型は全て string です。
        /// </summary>
        /// <param name="csvText"></param>
        /// <returns></returns>
        public List<string[]> Read(
            string string_Csv
            )
        {
            //
            // テーブルを作成します。
            //
            List<string[]> list_ArrayString = new List<string[]>();

            System.IO.StringReader reader = new System.IO.StringReader(string_Csv);
            CsvLineParserImpl csvParser = new CsvLineParserImpl();

            // CSVを解析して、テーブル形式で格納。
            {
                int nRowIndex = 0;
                while (-1 < reader.Peek())
                {
                    string sLine = reader.ReadLine();

                    //
                    // 配列の返却値を、ダイレクトに渡します。
                    //
                    string[] sFields = csvParser.UnescapeLineToFieldList(sLine, this.CharSeparator).ToArray();
                    list_ArrayString.Add(sFields);

                    nRowIndex++;
                }
            }

            // ストリームを閉じます。
            reader.Close();

            return list_ArrayString;
        }
开发者ID:muzudho,项目名称:XtA,代码行数:42,代码来源:CsvTo_ListArrayImpl.cs

示例10: btnExcute_Click

        private void btnExcute_Click(object sender, EventArgs e)
        {
            try
            {
                var helper = new UBA.Http.HttpHelper();
                var param = "query=" + this.richTextBox1.Text.Trim();
                var result = helper.GetHtml(
                    new UBA.Http.HttpItem
                    {
                        URL = url,
                        Method = "POST",
                        Postdata = param,
                        ResultType = ResultType.String,
                        ContentType = "application/x-www-form-urlencoded; charset=UTF-8"

                    });
                var str = result.Html;
                //var db = new DataTable();

                // using(System.IO.Stream stream=new System.IO.StringReader(str))
                DataSet ds = new DataSet();

                var a = new System.IO.StringReader(str);
                ds.ReadXml(a);
                var db = ds.Tables[0];
                this.dataGridView1.DataSource = db;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:rexyanglucky,项目名称:uba,代码行数:32,代码来源:Form1.cs

示例11: testCnAnalyzer

        //static void Main(string[] args)
        //{
        //    SetEnvironmentVariable( "dic.dir", "F:/lwh/TestLucene/TestLucene/dic");
        //    //
        //    // TODO: 在此处添加代码以启动应用程序
        //    //
        //    testCnAnalyzer();
        //    System.Console.Read();
        //}
		
		public static void testCnAnalyzer() 
		{
			System.IO.TextReader input;

            try
            {
                CnTokenizer.makeTag = true;
            }
            //catch()
            //{
            //}
            finally
            {
                string sentence = "邀请王振国今年9月参加在洛杉矶举行的30届美国治癌成就大奖会";

                input = new System.IO.StringReader(sentence);
                TokenStream tokenizer = new seg.result.CnTokenizer(input);

                for (Token t = tokenizer.Next(); t != null; t = tokenizer.Next())
                {
                    System.Console.WriteLine(t.TermText() + " " + t.StartOffset() + " "
                        + t.EndOffset() + " " + t.Type());
                }
            }
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:35,代码来源:Class1.cs

示例12: TranslitEncoderFallbackBuffer

        static TranslitEncoderFallbackBuffer()
        {
            transliterations = new Dictionary<char, string>(3900);

            // initialize the transliterations table:

            // load "translit.def" file content:
            using (var translit = new System.IO.StringReader(Strings.translit))
            {
                string line;
                while ((line = translit.ReadLine()) != null)
                {
                    // remove comments:
                    int cut_from = line.IndexOf('#');
                    if (cut_from >= 0) line = line.Remove(cut_from);

                    // skip empty lines:
                    if (line.Length == 0) continue;

                    //
                    string[] parts = line.Split('\t');  // HEX\tTRANSLIT\t
                    Debug.Assert(parts != null && parts.Length == 3);

                    int charNumber = int.Parse(parts[0], System.Globalization.NumberStyles.HexNumber);
                    string str = parts[1];

                    if (transliterationsMaxCharCount < str.Length)
                        transliterationsMaxCharCount = str.Length;

                    transliterations[(char)charNumber] = str;
                }
            }
        }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:33,代码来源:TranslitEncoderFallback.cs

示例13: ResolveImports

        private String ResolveImports(String Path, List<String> FilesLoaded = null)
        {
            Path = Path.Replace('\\', '/');
            if (FilesLoaded == null) FilesLoaded = new List<String>();
            else if (FilesLoaded.Contains(Path))
                return "";
            FilesLoaded.Add(Path);

            var source = LoadSourceFile(Path);
            if (source.Item1 == false)
            {
                Core.LogError(Path + " - " + source.Item2);
                return "";
            }

            var output = new StringBuilder();
            var stream = new System.IO.StringReader(source.Item2);
            while (true)
            {
                var line = stream.ReadLine();
                if (line == null) break;

                if (line.StartsWith("//import "))
                {
                    var importedFilename = line.Substring("//import ".Length).Trim();
                    output.Append(ResolveImports(importedFilename, FilesLoaded));
                    output.AppendLine();
                }
                else
                    output.AppendLine(line);
            }

            return output.ToString();
        }
开发者ID:Reddit-Mud,项目名称:RMUD,代码行数:34,代码来源:Preprocess.cs

示例14: ReadSensorData

 public static SensorData ReadSensorData(string soap) {
      SensorData sd;
      XmlTextReader xmread;
      sd = null;
      try {
           sd = new SensorData();
           using (System.IO.StringReader read = new System.IO.StringReader(soap)) {
                xmread = new XmlTextReader(read);
                xmread.ReadStartElement("SensorDataContainer");
                xmread.ReadStartElement("Sensor");
                xmread.ReadStartElement("HasMotion");
                sd.HasMotion = bool.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("NodeId");
                sd.NodeId = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("PowerLevel");
                sd.PowerLevel = int.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadStartElement("TimeStamp");
                sd.TimeStamp = DateTime.Parse(xmread.ReadString());
                xmread.ReadEndElement();
                xmread.ReadEndElement();
                xmread.ReadEndElement();
           }
      } catch (Exception) {
           throw;
      }
      return (sd);
 }
开发者ID:wendellinfinity,项目名称:Electricity-Monitor-.Net,代码行数:30,代码来源:SensorData.cs

示例15: DecodeInterviewAnswers

 /// <summary>
 /// Decodes answers from an interview passed as a string.
 /// </summary>
 /// <param name="input">String that contains answers to decode.</param>
 public void DecodeInterviewAnswers(string input)
 {
     using (var rdr = new System.IO.StringReader(input))
     {
         DecodeInterviewAnswers(rdr);
     }
 }
开发者ID:W800RDY,项目名称:hotdocs-open-sdk,代码行数:11,代码来源:InterviewAnswerSet.cs


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