本文整理汇总了C#中System.IO.StringReader类的典型用法代码示例。如果您正苦于以下问题:C# System.IO.StringReader类的具体用法?C# System.IO.StringReader怎么用?C# System.IO.StringReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.IO.StringReader类属于命名空间,在下文中一共展示了System.IO.StringReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: LoadConfigByType
/// <summary>
/// 通过类型获取 配置信息类 对象
/// </summary>
/// <paramKey name="type">可序列化的类类型</paramKey>
/// <returns></returns>
public static object LoadConfigByType(Type type)
{
try
{
//配置文件
fileName = System.IO.Path.Combine(ConfigDirectory, fileName);
string fname = type.FullName;
//去掉+ ,当是内部类时会出现加号
fname = fname.Replace("+", ".");
//找到对应节点
string value = GetObjString(fname);
if (value.Equals(string.Empty))
{
return new object();
}
//找对应字符串
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type);
//System.IO.StreamReader sr = new System.IO.StreamReader(localConfigPath);
System.IO.StringReader sr = new System.IO.StringReader(value);
object obj = xs.Deserialize(sr);
//反序列化
return obj;
}
catch
{
return new object();
}
}
开发者ID:sunpander,项目名称:VSDT,代码行数:36,代码来源:XMLConfigUtility.cs
示例17: ListContainers
public List<Container> ListContainers(
string prefix = null,
bool IncludeMetadata = false,
int timeoutSeconds = 0,
Guid? xmsclientrequestId = null)
{
List<Container> lContainers = new List<Container>();
string strNextMarker = null;
do
{
string sRet = Internal.InternalMethods.ListContainers(
AccountName, SharedKey, UseHTTPS,
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);
}
lContainers.AddRange(Container.ParseFromXMLEnumerationResults(this, doc));
strNextMarker = Container.GetNextMarkerFromXMLEnumerationResults(doc);
} while (!string.IsNullOrEmpty(strNextMarker));
return lContainers;
}
开发者ID:DomG4,项目名称:sqlservertoazure,代码行数:31,代码来源:AzureBlobService.cs
示例18: GetTokens
public static IEnumerable<Token> GetTokens(string cssFilter)
{
var reader = new System.IO.StringReader(cssFilter);
while (true)
{
int v = reader.Read();
if (v < 0)
yield break;
char c = (char)v;
if (c == '>')
{
yield return new Token(">");
continue;
}
if (c == ' ' || c == '\t')
continue;
string word = c + ReadWord(reader);
yield return new Token(word);
}
}
开发者ID:ccwalkerjm,项目名称:HtmlAgilityPack.CssSelector,代码行数:25,代码来源:Tokenizer.cs
示例19: ReadSensorData
public static SensorData ReadSensorData(string soap) {
SensorData sd;
sd = null;
try {
sd = new SensorData();
using (System.IO.StringReader read = new System.IO.StringReader(soap)) {
using (XmlReader xmread = XmlReader.Create(read)) {
xmread.ReadStartElement("SensorDataContainer");
xmread.ReadStartElement("Sensor");
xmread.ReadStartElement("HasMotion");
sd.HasMotion = xmread.ReadContentAsBoolean();
xmread.ReadEndElement();
xmread.ReadStartElement("NodeId");
sd.NodeId = xmread.ReadContentAsInt();
xmread.ReadEndElement();
xmread.ReadStartElement("PowerLevel");
sd.PowerLevel = xmread.ReadContentAsInt();
xmread.ReadEndElement();
xmread.ReadStartElement("TimeStamp");
sd.TimeStamp = xmread.ReadContentAsDateTime();
xmread.ReadEndElement();
xmread.ReadEndElement();
xmread.ReadEndElement();
}
}
} catch (Exception) {
throw;
}
return (sd);
}
开发者ID:wendellinfinity,项目名称:Electricity-Monitor-.Net,代码行数:30,代码来源:SensorData.cs
示例20: PostProcess
/// <summary>Called when extension shall process generated code</summary>
/// <param name="code">The code</param>
/// <param name="provider">CodeDOM provider (the language)</param>
/// <version version="1.5.3">Parameter <c>Provider</c> renamed to <c>provider</c></version>
public void PostProcess(ref string code, CodeDomProvider provider)
{
System.IO.StringWriter tw = new System.IO.StringWriter();
provider.GenerateCodeFromStatement(new CodeCommentStatement(FirtsLineOfAccessor), tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
string srch = tw.GetStringBuilder().ToString();
if (srch.EndsWith("\r\n")) srch = srch.Substring(0, srch.Length - 2);
else if (srch.EndsWith("\r") || srch.EndsWith("\n")) srch = srch.Substring(0, srch.Length - 1);
tw = new System.IO.StringWriter();
CodeTypeDeclaration foo = new CodeTypeDeclaration("foo");
foo.CustomAttributes.Add(NewAttribute);
provider.GenerateCodeFromType(foo, tw, new System.CodeDom.Compiler.CodeGeneratorOptions());
string attr = new System.IO.StringReader(tw.GetStringBuilder().ToString()).ReadLine();
System.IO.StringReader sr = new System.IO.StringReader(code);
List<String> Lines = new List<string>();
do {
string line = sr.ReadLine();
if (line == null) break;
if (line.EndsWith(srch))
Lines[Lines.Count - 1] = attr + "\r\n" + Lines[Lines.Count - 1];
else
Lines.Add(line);
} while (true);
System.Text.StringBuilder b = new System.Text.StringBuilder();
foreach (string line in Lines)
b.AppendLine(line);
code = b.ToString();
}
开发者ID:wskplho,项目名称:Tools,代码行数:31,代码来源:DebuggerStepThrough.cs
注:本文中的System.IO.StringReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论