예제 #1
0
        public static bool TryLoad <T>(FileDescriptor fileName, ProgressReporter progress, out T result, T @default, ObjectSerialiser serialiser)
        {
            if (!File.Exists(fileName))
            {
                result = @default;
                return(false);
            }

            try
            {
                using (FileStream sr = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                {
                    if (progress != null)
                    {
                        using (ProgressStream ps = new ProgressStream(sr, progress))
                        {
                            result = _Deserialise <T>(ps, fileName.Format, serialiser, progress);
                        }
                    }
                    else
                    {
                        result = _Deserialise <T>(sr, fileName.Format, serialiser, progress);
                    }
                }

                return(true);
            }
            catch
            {
                result = @default;
                return(false);
            }
        }
예제 #2
0
        public PathwayToolsReader(string fn, ProgressReporter prog)
        {
            _fn = fn;
            FileStream     fs = File.OpenRead(fn);
            ProgressStream ps = new ProgressStream(fs, prog);

            _sr = new StreamReader(ps);
        }