/// <summary>
        /// Unpacks the zip-file and constructs a new FileArtifactSource on the unzipped directory
        /// </summary>
        /// <remarks>This is an expensive operations and should be run once. As well, it unpacks files on the
        /// file system and is not thread-safe.</remarks>
        private void prepare()
        {
            if (_prepared) return;

            if (!File.Exists(_zipPath)) throw new FileNotFoundException(String.Format("Cannot prepare ZipArtifactSource: file '{0}' was not found", _zipPath ));
           
            var zc = new ZipCacher(_zipPath, CACHE_KEY);
            _filesSource = new FileDirectoryArtifactSource(zc.GetContentDirectory(), includeSubdirectories: false);

            _prepared = true;
        }
示例#2
0
        /// <summary>
        /// Unpacks the zip-file and constructs a new FileArtifactSource on the unzipped directory
        /// </summary>
        /// <remarks>This is an expensive operations and should be run once. As well, it unpacks files on the
        /// file system and is not thread-safe.</remarks>
        private DirectorySource createSource()
        {
            if (!File.Exists(ZipPath))
            {
                throw new FileNotFoundException($"Cannot prepare {nameof(ZipSource)}: file '{ZipPath}' was not found");
            }

            var zc     = new ZipCacher(ZipPath, GetCacheKey());
            var source = new DirectorySource(zc.GetContentDirectory(), _settings);

            var mask = Mask;

            if (!string.IsNullOrEmpty(mask))
            {
                source.Mask = mask;
            }
            return(source);
        }
示例#3
0
        /// <summary>
        /// Unpacks the zip-file and constructs a new FileArtifactSource on the unzipped directory
        /// </summary>
        /// <remarks>This is an expensive operations and should be run once. As well, it unpacks files on the
        /// file system and is not thread-safe.</remarks>
        private void prepare()
        {
            if (_prepared)
            {
                return;
            }

            if (!File.Exists(_zipPath))
            {
                throw new FileNotFoundException(String.Format("Cannot prepare ZipArtifactSource: file '{0}' was not found", _zipPath));
            }

            var zc = new ZipCacher(_zipPath, CACHE_KEY);

            _filesSource = new FileDirectoryArtifactSource(zc.GetContentDirectory(), includeSubdirectories: false);

            _prepared = true;
        }
示例#4
0
        private string prepareExampleDirectory()
        {
            var zipFile = Path.Combine(Directory.GetCurrentDirectory(), "validation.xml.zip");
            var zip = new ZipCacher(zipFile);
            var zipPath = zip.GetContentDirectory();

            var testPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            Directory.CreateDirectory(testPath);

            copy(zipPath, "extension-definitions.xml", testPath);
            copy(zipPath, "flag.xsd", testPath);
            copy(zipPath, "patient.sch", testPath);
            copy(@"TestData", "TestPatient.xml", testPath);
            File.WriteAllText(Path.Combine(testPath, "bla.dll"), "This is text, acting as a dll");

            Directory.CreateDirectory(Path.Combine(testPath, "sub"));
            copy(@"TestData", "TestPatient.json", testPath);

            return testPath;
        }