예제 #1
0
        internal FileStreamIfc getStreamReader(string fileName)
        {
            string ext = Path.GetExtension(fileName);

            FileName   = fileName;
            FolderPath = Path.GetDirectoryName(fileName);
            FormatIfc format = fileName.EndsWith("xml") ? FormatIfc.XML : FormatIfc.STEP;

            if (fileName.EndsWith("json"))
            {
                format = FormatIfc.JSON;
            }
#if (!NOIFCZIP)
            if (fileName.ToLower().EndsWith("zip"))
            {
                System.IO.Compression.ZipArchive za = System.IO.Compression.ZipFile.OpenRead(fileName);
                if (za.Entries.Count != 1)
                {
                    return(null);
                }
                string filename = za.Entries[0].Name.ToLower();
                format = filename.EndsWith("xml") ? FormatIfc.XML : FormatIfc.STEP;
                if (filename.EndsWith("json"))
                {
                    format = FormatIfc.JSON;
                }
                StreamReader str = (format == FormatIfc.STEP ? new StreamReader(za.Entries[0].Open(), System.Text.Encoding.GetEncoding("windows-1252")) :
                                    new StreamReader(za.Entries[0].Open()));
                return(new FileStreamIfc(format, str));
            }
#endif
            StreamReader sr = format == FormatIfc.STEP ? new StreamReader(fileName, System.Text.Encoding.GetEncoding("windows-1252")) :
                              new StreamReader(fileName);
            return(new FileStreamIfc(format, sr));
        }
예제 #2
0
 internal FileStreamIfc(FormatIfc format, StreamReader sr)
 {
     mFormat = format;
     mStreamReader = sr;
 }
예제 #3
0
 internal FileStreamIfc(FormatIfc format, StreamReader sr)
 {
     mFormat       = format;
     mStreamReader = sr;
 }
예제 #4
0
 internal FileStreamIfc(FormatIfc format, TextReader sr)
 {
     mFormat     = format;
     mTextReader = sr;
 }