예제 #1
0
        public static string SniffType(Stream stream)
        {
            long pos = stream.Position;

            try
            {
                using (var reader = new NoCloseStreamReader(stream, Encoding.GetEncoding(1252), detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE))
                {
                    for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
                    {
                        if (line.Length == 0 || comment.IsMatch(line))
                        {
                            continue;
                        }

                        if (sniff_tab.IsMatch(line))
                        {
                            return("TabDelimited");
                        }

                        if (sniff_ss.IsMatch(line))
                        {
                            return("SecondSurvey");
                        }
                    }
                    return(null);
                }
            }
            finally
            {
                stream.Position = pos;
            }
        }
 public static string SniffType(Stream stream)
 {
     long pos = stream.Position;
     try
     {
         using (var reader = new NoCloseStreamReader(stream, Encoding.GetEncoding(1252), detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE))
         {
             string line = reader.ReadLine();
             if (sniff_xml.IsMatch(line))
                 return "XML";
         }
         return "MSEC";
     }
     finally
     {
         stream.Position = pos;
     }
 }
예제 #3
0
        public static string SniffType(Stream stream)
        {
            long pos = stream.Position;

            try
            {
                using (var reader = new NoCloseStreamReader(stream, Encoding.GetEncoding(1252), detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE))
                {
                    string line = reader.ReadLine();
                    if (line != null && SNIFF_XML_REGEX.IsMatch(line))
                    {
                        return("XML");
                    }
                }
                return("MSEC");
            }
            finally
            {
                stream.Position = pos;
            }
        }
예제 #4
0
        public static string SniffType(Stream stream)
        {
            long pos = stream.Position;
            try
            {
                using (var reader = new NoCloseStreamReader(stream, Encoding.GetEncoding(1252), detectEncodingFromByteOrderMarks: true, bufferSize: BUFFER_SIZE))
                {
                    for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
                    {
                        if (line.Length == 0 || comment.IsMatch(line))
                            continue;

                        if (sniff_tab.IsMatch(line))
                            return "TabDelimited";

                        if (sniff_ss.IsMatch(line))
                            return "SecondSurvey";
                    }
                    return null;
                }
            }
            finally
            {
                stream.Position = pos;
            }
        }