Exemplo n.º 1
0
    public async Task <T> ImportAsync(
        string path,
        ulong ignoreFlags,
        XmlReaderSettings settings,
        IProgress <float> progress,
        CancellationToken cancel)
    {
        long currentBytes = 0L;

        using (ProgressStream f = new ProgressStream(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), null, null))
            using (XmlReader r = XmlReader.Create(f, settings))
            {
                if (progress != null)
                {
                    float length = f.Length;
                    f.SetReadProgress(new BasicProgress <int>(i =>
                    {
                        currentBytes += i;
                        progress.Report(currentBytes / length);
                    }));
                }
                return(await ImportAsync(r, ignoreFlags, cancel));
            }
    }