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


C# StringReader.ReadToEnd方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:bcl-lab-apps,项目名称:EMRGENE,代码行数:27,代码来源:EncryptedObjectStore.cs

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

示例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;
        }
开发者ID:ernstnaezer,项目名称:Manssiere,代码行数:30,代码来源:Shader.cs

示例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;
 }
开发者ID:camradal,项目名称:DishReaderApp,代码行数:33,代码来源:FeedRepository.cs

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

示例6: GetFileAsString

 public static string GetFileAsString(string file)
 {
     using (StringReader reader = new StringReader(file))
     {
         return reader.ReadToEnd();
     }
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:7,代码来源:FileMaker.cs

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

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

示例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;
        }
开发者ID:BackupTheBerlios,项目名称:opendx2,代码行数:31,代码来源:WizardDialog.cs

示例10: StringReaderWithEmptyString

 public static void StringReaderWithEmptyString()
 {
     // [] Check vanilla construction
     //-----------------------------------------------------------
     StringReader sr = new StringReader(string.Empty);
     Assert.Equal(string.Empty, sr.ReadToEnd());
 }
开发者ID:Corillian,项目名称:corefx,代码行数:7,代码来源:StringReader.CtorTests.cs

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

示例12: StringReaderWithGenericString

        public static void StringReaderWithGenericString()
        {
            // [] Another vanilla construction
            //-----------------------------------------------------------

            StringReader sr = new StringReader("Hello\0World");
            Assert.Equal("Hello\0World", sr.ReadToEnd());
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:StringReaderCtorTests.cs

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

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

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


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