當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。