Esempio n. 1
0
 static ApplicationInfo()
 {
     Applicaition          = Assembly.GetEntryAssembly() ?? Assembly.GetExecutingAssembly();
     ApplicationData       = IOUtility.CombinePath(Environment.SpecialFolder.ApplicationData, Name);
     CommonApplicationData = IOUtility.CombinePath(Environment.SpecialFolder.CommonApplicationData, Name);
     Directory             = AppDomain.CurrentDomain.BaseDirectory;
     RunningInMono         = Type.GetType(MonoRuntimeType) != null;
 }
Esempio n. 2
0
        public async Task ExtractContainerAsync(string outputDirecotry, IProgress <double> progress = null, CancellationToken cancellationToken = default)
        {
            if (!Directory.Exists(outputDirecotry))
            {
                _ = Directory.CreateDirectory(outputDirecotry);
            }

            PackagePartCollection parts = _package.GetParts();

            int index = 0;

            int count = parts.Count();

            Progress <double> innerProgress = new Progress <double> {
            };

            innerProgress.ProgressChanged += (o, e) =>
            {
                double percent = (index + e) / count;
                progress.Report(percent);
            };

            if (progress == null)
            {
                innerProgress = null;
            }

            foreach (PackagePart part in parts)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    cancellationToken.ThrowIfCancellationRequested();
                }

                string name = part.Uri.ToString();
                string path = IOUtility.CombinePath(outputDirecotry, name);
                using FileStream fs = File.OpenWrite(path);
                await GetAsync(name, fs, innerProgress);

                index++;
            }
        }
Esempio n. 3
0
 protected override void Establish_That()
 {
     _specialFolder = Environment.SpecialFolder.ApplicationData;
     _path          = Random.NextString();
     _combinedPath  = IOUtility.CombinePath(_specialFolder, _path);
 }
Esempio n. 4
0
 protected override void Because_Of()
 {
     _combinedPath = IOUtility.CombinePath(_paths);
 }
Esempio n. 5
0
 protected override void Because_Of()
 {
     _result = IOUtility.CombinePath(_specialFolder, _path);
 }