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


C# TextReader.ReadToEnd方法代码示例

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


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

示例1: Parse

        /// <summary>
        /// Parse a query string
        /// </summary>
        /// <param name="reader">string to parse</param>
        /// <param name="parameters">Parameter collection to fill</param>
        /// <returns>A collection</returns>
        /// <exception cref="ArgumentNullException"><c>reader</c> is <c>null</c>.</exception>
        public void Parse(TextReader reader, IParameterCollection parameters)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");

            var canRun = true;
            while (canRun)
            {
                var result = reader.ReadToEnd("&=");
                var name = Uri.UnescapeDataString(result.Value);
                switch (result.Delimiter)
                {
                    case '&':
                        parameters.Add(name, string.Empty);
                        break;
                    case '=':
                        result = reader.ReadToEnd("&");
                        parameters.Add(name, Uri.UnescapeDataString(result.Value));
                        break;
                    case char.MinValue:
                        // EOF = no delimiter && no value
                        if (!string.IsNullOrEmpty(name))
                            parameters.Add(name, string.Empty);
                        break;
                }

                canRun = result.Delimiter != char.MinValue;
            }
        }
开发者ID:2594636985,项目名称:griffin.networking,代码行数:36,代码来源:UrlDecoder.cs

示例2: Exec

        public static int Exec(string filename, string args, TextReader stdIn = null, TextWriter stdOut = null, TextWriter stdErr = null, Encoding encoding = null, string workingDirectory = null)
        {
            using (Process process = new Process())
            {
                ProcessStartInfo psi = process.StartInfo;
                psi.RedirectStandardError = psi.RedirectStandardInput = psi.RedirectStandardOutput = true;
                psi.UseShellExecute = false;
                psi.CreateNoWindow = true;
                psi.FileName = filename;
                psi.Arguments = args;
                if (workingDirectory != null)
                    psi.WorkingDirectory = workingDirectory;

                if (encoding != null)
                {
                    psi.StandardOutputEncoding = encoding;
                    psi.StandardErrorEncoding = encoding;
                }

                if (stdOut != null)
                {
                    process.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e)
                    {
                        stdOut.WriteLine(e.Data);
                    };
                }
                if (stdErr != null)
                {
                    process.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e)
                    {
                        stdErr.WriteLine(e.Data);
                    };
                }
                process.Start();
                process.BeginOutputReadLine();
                process.BeginErrorReadLine();

                if (stdIn != null)
                {
                    if (encoding != null)
                    {
                        // There's no Process.Standard*Input*Encoding, so write specified encoding's raw bytes to base input stream
                        using (var encodedStdIn = new StreamWriter(process.StandardInput.BaseStream, encoding))
                            encodedStdIn.Write(stdIn.ReadToEnd());
                    }
                    else
                    {
                        using (process.StandardInput)
                            process.StandardInput.Write(stdIn.ReadToEnd());
                    }
                }

                process.WaitForExit();
                return process.ExitCode;
            }
        }
开发者ID:duncansmart,项目名称:LessCoffee,代码行数:56,代码来源:ProcessUtil.cs

示例3: Parse

 public override void Parse(TextReader reader, IProcessorContext context)
 {
     if (AssetPipeline.MinifyJs)
     {
         var compressor = new JavaScriptCompressor(reader.ReadToEnd());
         context.Output.Write(compressor.Compress());
     }
     else
     {
         context.Output.Write(reader.ReadToEnd());
     }
 }
开发者ID:pvasek,项目名称:nsprockets,代码行数:12,代码来源:JsProcessor.cs

示例4: Parse

        /// <summary>
        /// Parses the specified pattern returned by the reader and localizes error messages with the text manager specified
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="textManager">The text manager.</param>
        /// <returns></returns>
        public override Expression Parse(TextReader reader, TextManager textManager)
        {
            try
            {
                _reader = reader.ReadToEnd();

                _pos = -1;

                MoveNext();

                var expr = ParseExpression();
                if (_current != Eof)
                {
                    UnexpectedToken("Expression", "" + _current);
                }

                expr.Accept(_trimmer);

                return expr;
            }
            catch (InnerParserException template)
            {
                throw new SyntaxErrorException(template.Message, template.Construct, template.Pos);
            }
        }
开发者ID:nikolajw,项目名称:localizationnet,代码行数:31,代码来源:DefaultExpressionParser.cs

示例5: ReaderPackageJsonSource

        public ReaderPackageJsonSource(TextReader reader) {
            try {
                var text = reader.ReadToEnd();
                try {
                    // JsonConvert and JObject.Parse exhibit slightly different behavior,
                    // so fall back to JObject.Parse if JsonConvert does not properly deserialize
                    // the object.
                    Package = JsonConvert.DeserializeObject(text);
                } catch (ArgumentException) {
                    Package = JObject.Parse(text);
                }
            } catch (JsonReaderException jre) {
                WrapExceptionAndRethrow(jre);
            } catch (JsonSerializationException jse) {
                WrapExceptionAndRethrow(jse);
            } catch (FormatException fe) {
                WrapExceptionAndRethrow(fe);
            } catch (ArgumentException ae) {
                throw new PackageJsonException(
                    string.Format(CultureInfo.CurrentCulture, @"Error reading package.json. The file may be parseable JSON but may contain objects with duplicate properties.

The following error occurred:

{0}", ae.Message),
                    ae);
            }
        }
开发者ID:paladique,项目名称:nodejstools,代码行数:27,代码来源:ReaderPackageJsonSource.cs

示例6: Deserialize

        public override object Deserialize(TextReader tr)
        {
            if (tr != null)
            {
                string value = tr.ReadToEnd();

                ICalendarObject co = SerializationContext.Peek() as ICalendarObject;
                if (co != null)
                {
                    EncodableDataType dt = new EncodableDataType();
                    dt.AssociatedObject = co;
                    value = Decode(dt, value);
                }

                value = TextUtil.Normalize(value, SerializationContext).ReadToEnd();

                try
                {
                    Uri uri = new Uri(value);
                    return uri;
                }
                catch
                {
                }
            }
            return null;
        }
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:27,代码来源:UriSerializer.cs

示例7: Execute

 /// <summary>
 /// Execute script from stream.
 /// </summary>
 public void Execute(TextReader reader)
 {
     // Read script
       string script = reader.ReadToEnd();
       // Execute
       ExecuteScriptText(script);
 }
开发者ID:ZoolooDan,项目名称:bug-db-analyzer,代码行数:10,代码来源:SqlScriptRunner.cs

示例8: Deserialize

		public object Deserialize (TextReader input)
		{
			if (input == null)
				throw new ArgumentNullException ("input");

			return Deserialize (input.ReadToEnd ());
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:LosFormatter.cs

示例9: Parse

        /// <summary>
        /// Parse and filter the supplied modifications.  The position of each modification in the list is used as the ChangeNumber.
        /// </summary>
        /// <param name="history"></param>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public Modification[] Parse(TextReader history, DateTime from, DateTime to)
        {
            StringReader sr = new StringReader(string.Format(@"<ArrayOfModification xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">{0}</ArrayOfModification>"
                , history.ReadToEnd()));

            XmlSerializer serializer = new XmlSerializer(typeof(Modification[]));
            Modification[] mods;
            try
            {
                mods = (Modification[])serializer.Deserialize(sr);
            }
            catch (Exception ex)
            {
                throw new CruiseControlException("History Parsing Failed", ex);
            }

            ArrayList results = new ArrayList();
            int change = 0;
            foreach (Modification mod in mods)
            {
                change++;
                mod.ChangeNumber = change;
                if ((mod.ModifiedTime >= from) & (mod.ModifiedTime <= to))
                {
                    results.Add(mod);
                }
            }
            return (Modification[])results.ToArray(typeof(Modification));
        }
开发者ID:MsPenghao,项目名称:ccnet.git.plugin,代码行数:36,代码来源:gitHistoryParser.cs

示例10: ObjectMapTable

        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectMapTable"/> class.
        /// </summary>
        /// <param name="bufferedReader">The buffered reader.</param>
        public ObjectMapTable(TextReader bufferedReader)
            : this()
        {
            try
            {
                XmlDocument XmlData = new XmlDocument();
                XmlData.LoadXml(bufferedReader.ReadToEnd());

                //add projects to treeview

                XmlNodeList Classes = XmlData.SelectNodes("ObjectMap/Class");
                if (Classes != null && Classes.Count > 0)
                {
                    foreach (XmlElement nodeClass in Classes)
                    {
                        // Add path and class to the object mapping
                        ObjectMapping theMapping = new ObjectMapping(nodeClass);
                        _objectMapList.Add(theMapping);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("error reading map file", ex);
            }
            finally
            {
                bufferedReader.Close();
            }
        }
开发者ID:KristenWegner,项目名称:expergent,代码行数:34,代码来源:ObjectMapTable.cs

示例11: Parse

        public object Parse(TextReader sourceReader)
        {
            if (sourceReader == null)
                throw new ArgumentNullException("sourceReader");

            return Parse(new TextParser(sourceReader.ReadToEnd()));
        }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:7,代码来源:DelimitedListParser.cs

示例12: Deserialize

        public override object Deserialize(TextReader tr)
        {
            string value = tr.ReadToEnd();

            IUTCOffset offset = CreateAndAssociate() as IUTCOffset;
            if (offset != null)
            {
                // Decode the value as necessary
                value = Decode(offset, value);

                Match match = Regex.Match(value, @"(\+|-)(\d{2})(\d{2})(\d{2})?");
                if (match.Success)
                {
                    try
                    {
                        // NOTE: Fixes bug #1874174 - TimeZone positive UTCOffsets don't parse correctly
                        if (match.Groups[1].Value == "+")
                            offset.Positive = true;
                        offset.Hours = Int32.Parse(match.Groups[2].Value);
                        offset.Minutes = Int32.Parse(match.Groups[3].Value);
                        if (match.Groups[4].Success)
                            offset.Seconds = Int32.Parse(match.Groups[4].Value);
                    }
                    catch
                    {
                        return null;
                    }
                    return offset;
                }

                return false;
            }
            return null;
        }
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:34,代码来源:UTCOffsetSerializer.cs

示例13: Parse

		/// <inheritdoc />
		public IParseForest Parse(TextReader reader)
		{
			// CONTRACT: Inherited from IParser

			// Unger requires the whole input to be known beforehand.
			return Parse(reader.ReadToEnd());
		}
开发者ID:Virtlink,项目名称:noofax,代码行数:8,代码来源:UngerParser.cs

示例14: TokenStream

        public override TokenStream TokenStream(string fieldName, TextReader reader)
        {
            string str = reader.ReadToEnd();

            string[] parts = str.Split('.');

            StringBuilder tokenString = new StringBuilder();
            for (int i = 0; i < parts.Length; i++)
            {
                if (parts[i].IndexOf('(') > 0)
                    parts[i] = parts[i].Substring(0, parts[i].IndexOf('('));

                if (parts[i].IndexOf('<') > 0)
                    parts[i] = parts[i].Substring(0, parts[i].IndexOf('<'));

                parts[i] = new string(parts[i].Where(c => char.IsUpper(c) || char.IsNumber(c)).ToArray());
            }

            tokenString.AppendLine(parts[parts.Length - 1]);

            for (int i = parts.Length - 2; i >= 0; i--)
            {
                tokenString.AppendLine(string.Join(".", parts, i, parts.Length - i));
            }

            return new WhitespaceTokenizer(new StringReader(tokenString.ToString().ToLowerInvariant()));
        }
开发者ID:LBiNetherlands,项目名称:LBi.LostDoc,代码行数:27,代码来源:CamelCaseAnalyzer.cs

示例15: Parse

        public Modification[] Parse(TextReader history, DateTime from, DateTime to)
        {
            string historyLog = history.ReadToEnd();

            Regex regex = new Regex(Alienbrain.NO_CHANGE);
            if (regex.Match(historyLog).Success == true)
            {
                return new Modification[0];
            }

            regex = new Regex(FILE_REGEX);
            var result = new List<Modification>();
            string oldfile = ",";

            for (Match match = regex.Match(historyLog); match.Success; match = match.NextMatch())
            {
                string[] modificationParams = AllModificationParams(match.Value);
                if (modificationParams.Length > 1)
                {
                    string file = modificationParams[1];
                    if (file != oldfile)
                    {
                        result.Add(ParseModification(modificationParams));
                        oldfile = file;
                    }
                }
            }
            return result.ToArray();
        }
开发者ID:derrills1,项目名称:ccnet_gitmode,代码行数:29,代码来源:AlienbrainHistoryParser.cs


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