本文整理汇总了C#中System.IO.StringReader.ReadToEnd方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadToEnd方法的具体用法?C# StringReader.ReadToEnd怎么用?C# StringReader.ReadToEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StringReader
的用法示例。
在下文中一共展示了StringReader.ReadToEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAsync
public async Task<object> GetAsync(string key, Type type)
{
var encrypted = await m_inner.GetAsync(key, typeof(Encrypted)) as Encrypted;
if (encrypted == null)
{
return null;
}
try
{
string decryptedValue = m_cryptographer.Decrypt(m_encryptionKey, encrypted);
using (var reader = new StringReader(decryptedValue))
{
if (type == typeof(string))
{
return reader.ReadToEnd();
}
return HealthVaultClient.Serializer.Deserialize(reader, type, null);
}
}
catch (Exception)
{
return null;
}
}
示例2: WriteLine
public override void WriteLine(string format, params object[] arg)
{
base.WriteLine(format, arg);
TextReader stringReader = new StringReader(this.ToString());
String[] s = stringReader.ReadToEnd().Split(Environment.NewLine.ToCharArray());
//for (int i = 0; i < s.Length; i++) if (s[i].Trim().Length > 0) xbs_messages.addDebugMessage(" @ UPnP log: " + s[i].Trim());
}
示例3: Load
/// <summary>
/// Load a new shader
/// </summary>
/// <param name="vertexShader">The vertexshader.</param>
/// <param name="fragmentShader">The fragmentshader</param>
public static Shader Load(StringReader vertexShader, StringReader fragmentShader)
{
var shader = new Shader();
string vertexShaderCode = vertexShader.ReadToEnd();
string fragmentShaderCode = fragmentShader.ReadToEnd();
if (string.IsNullOrEmpty(vertexShaderCode) && string.IsNullOrEmpty(fragmentShaderCode))
{
throw new InvalidOperationException("Both vertex and fragement shader code are empty.");
}
if (string.IsNullOrEmpty(vertexShaderCode) == false)
{
shader.AttachShaderCode(vertexShaderCode, ShaderType.VertexShader);
}
if (string.IsNullOrEmpty(fragmentShaderCode) == false)
{
shader.AttachShaderCode(fragmentShaderCode, ShaderType.FragmentShader);
}
shader.Build();
return shader;
}
示例4: ExtractFeedItemsFromSyndicationString
private IEnumerable<FeedItem> ExtractFeedItemsFromSyndicationString(string value)
{
var items = new List<FeedItem>();
using (StringReader stringReader = new StringReader(value))
{
string content = stringReader.ReadToEnd();
content = content.Replace("-0001 00:00:00 +0000", string.Format("{0} 00:00:00 +0000", DateTime.Now.Year));
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(content);
using (XmlReader reader = XmlReader.Create(new MemoryStream(bytes)))
{
SyndicationFeed feed = SyndicationFeed.Load(reader);
foreach (SyndicationItem item in feed.Items)
{
try
{
items.Add(new FeedItem()
{
Title = htmlConverter.Convert(item.Title.Text),
Summary = htmlConverter.Convert(item.Summary.Text),
Url = item.Links[0].Uri,
PublishedDate = item.PublishDate.DateTime.AddHours(5).ToLocalTime(), // adjust for EST
IsNew = true
});
}
catch (Exception)
{
// ignore individual errors
}
}
}
}
return items;
}
示例5: Build
public void Build(ScriptInfo script)
{
using (TextReader reader = new StringReader(script.Code))
{
string line;
while ((line = reader.ReadLine()) != null)
{
MatchCollection matches = _regex.Matches(line);
if (matches.Count == 1)
{
Match match = matches[0];
string family = match.Groups["family"].Value;
string name = match.Groups["name"].Value;
BuildDependency(script, family, name);
}
else
{
while (line == "|")
{
line = reader.ReadLine();
}
break;
}
}
script.Code = string.Format("{1}{0}{2}{0}", Environment.NewLine, line, reader.ReadToEnd());
}
}
示例6: GetFileAsString
public static string GetFileAsString(string file)
{
using (StringReader reader = new StringReader(file))
{
return reader.ReadToEnd();
}
}
示例7: Main
static void Main(string[] args)
{
StringWriter w = new StringWriter();
w.WriteLine("Sing a song of {0} pence", 6);
string s = "A pocket full of rye";
w.Write(s);
w.Write(w.NewLine);
w.Write(string.Format(4 + " and " + 20 + " blackbirds"));
w.Write(new StringBuilder(" baked in a pie"));
w.WriteLine();
Console.WriteLine(w);
StringBuilder sb = w.GetStringBuilder();
int i = sb.Length;
sb.Append("The birds began to sing");
sb.Insert(i, "when the pie was opened\n");
sb.AppendFormat("\nWasn't that a {0} to set before the king", "dainty dish");
Console.WriteLine(w);
Console.WriteLine();
StringReader r = new StringReader(w.ToString());
string t = r.ReadLine();
Console.WriteLine(t);
Console.Write((char)r.Read());
char[] ca = new char[37];
r.Read(ca, 0, 19);
Console.Write(ca);
Console.WriteLine(r.ReadToEnd());
r.Close();
w.Close();
Console.ReadLine();
}
示例8: Template
/// <summary>
/// Initializes a new instance of Template with specified StringReader containing template text.
/// </summary>
/// <param name="reader">StringReader containing template text.</param>
public Template(StringReader reader)
{
if(reader == null)
throw new ArgumentNullException("reader");
this.data = reader.ReadToEnd();
}
示例9: getText
public override string getText()
{
if (text != null && text.Length > 0) return text;
if (file_read) return null;
file_read = true;
String uiroot = MainProgram.theApplication.getUIRoot();
Debug.Assert(uiroot != null);
if (uiroot.ToCharArray()[uiroot.Length-1] != '/')
uiroot += "/";
if (Parent == null || Parent.Name == null)
return null;
uiroot += "/ui/" + Parent.Name;
try
{
TextReader tr = new StringReader(uiroot);
text = tr.ReadToEnd();
}
catch (Exception e)
{
return null;
}
return text;
}
示例10: StringReaderWithEmptyString
public static void StringReaderWithEmptyString()
{
// [] Check vanilla construction
//-----------------------------------------------------------
StringReader sr = new StringReader(string.Empty);
Assert.Equal(string.Empty, sr.ReadToEnd());
}
示例11: ExtractQuery
public static string ExtractQuery(string fileName, TextWriter errorlogger)
{
try
{
string data = File.ReadAllText(fileName);
XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None);
Stream xmlFragment = new MemoryStream(Encoding.UTF8.GetBytes(data));
XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Element, context);
reader.MoveToContent();
if (reader.NodeType == XmlNodeType.Text)
{
return data;
}
XmlReader reader2 = reader.ReadSubtree();
StringBuilder output = new StringBuilder();
using (XmlWriter writer = XmlWriter.Create(output))
{
writer.WriteNode(reader2, true);
}
StringReader reader3 = new StringReader(data);
for (int i = 0; i < reader.LineNumber; i++)
{
reader3.ReadLine();
}
return reader3.ReadToEnd().Trim();
}
catch (Exception ex)
{
errorlogger.WriteLine(ex.Message);
errorlogger.WriteLine(ex.StackTrace);
}
return string.Format("//Error loading the file - {0} .The the linq file might be a linqpad expression which is not supported in the viewer currently." ,fileName);
}
示例12: StringReaderWithGenericString
public static void StringReaderWithGenericString()
{
// [] Another vanilla construction
//-----------------------------------------------------------
StringReader sr = new StringReader("Hello\0World");
Assert.Equal("Hello\0World", sr.ReadToEnd());
}
示例13: ReadFromShouldConsumeTheCorrectNumberOfSyllablesFromTheInput
public void ReadFromShouldConsumeTheCorrectNumberOfSyllablesFromTheInput()
{
var input = new StringReader("out of the water out of itself");
var line = new Line(5);
line.ReadFrom(input);
Assert.AreEqual("out of the water", line.ToString());
Assert.AreEqual("out of itself", input.ReadToEnd());
}
示例14: ReadAsciiData
private char[] ReadAsciiData()
{
string raw = ReadTextFile("Problem59.txt", true);
using (StringReader reader = new StringReader(raw))
{
string line = reader.ReadToEnd();
return line.Split(',').Select(x => Convert.ToChar(Int32.Parse(x))).ToArray();
}
}
示例15: LoadFailedPluginViewModel
public LoadFailedPluginViewModel(LoadFailedPluginData data)
{
this.Metadata = data.Metadata ?? new BlacklistedAssembly { Name = Path.GetFileName(data.FilePath) } as object;
using (var reader = new StringReader(data.Message))
{
this.Message = reader.ReadLine();
this.Exception = reader.ReadToEnd();
}
}