public virtual void SetUp()
        {
            //not a real file on disk, so I must populate it with content.
            var file = new InMemoryFile(filename);
            file.WriteLines(CreateFileContents(recordCount).ToArray());

            //            var file = LocalFileSystem.Instance.GetFile("../path/to/file.csv")
            reader = new MyCustomCsvReader(file);
        }
        IPackageInfo Publish(string packageFileName, Stream packageStream)
        {
            var fileWithoutExtension = packageFileName.Trim().ToLowerInvariant().EndsWith(".wrap")
                                               ? Path.GetFileNameWithoutExtension(packageFileName)
                                               : packageFileName;
            if (_packages.Any(x => x.FullName.EqualsNoCase(fileWithoutExtension)))
                throw new InvalidOperationException("Package already exists in repository.");

            var inMemoryFile = new InMemoryFile("c:\\" + Guid.NewGuid());
            using (var stream = FileExtensions.OpenWrite(inMemoryFile))
                packageStream.CopyTo(stream);

            var tempFolder = new CachedZipPackage(null, inMemoryFile, null, null);

            var package = new InMemoryPackage
            {
                    Name = PackageNameUtility.GetName(fileWithoutExtension),
                    Version = PackageNameUtility.GetVersion(fileWithoutExtension),
                    Source = this,
                    Dependencies = tempFolder.Dependencies.ToList(),
                    Anchored = tempFolder.Anchored
            };
            _packages.Add(package);
            return package;
        }
 protected void when_publishing_package(InMemoryFile package)
 {
     using (var stream = package.OpenRead())
     using(var publisher = Repository.Publisher())
         publisher.Publish(package.Name, stream);
 }
 protected InMemoryFile Package(string wrapName, string version, params string[] wrapdescLines)
 {
     var file = new InMemoryFile(wrapName + "-" + version + ".wrap");
     Packager.NewWithDescriptor(file, wrapName, version, wrapdescLines);
     return file;
 }
示例#5
0
 public Stream OpenStream()
 {
     var package = new InMemoryFile(@"c:\test.wrap");
     Packager.NewWithDescriptor(package, Name, Version.ToString(), Dependencies.Select(x => "depends: " + x).ToArray());
     return package.OpenRead();
 }
示例#6
0
 protected InMemoryFile Package(string name, string version, IEnumerable<PackageContent> content, params string[] descriptorLines)
 {
     var file = new InMemoryFile(name + "-" + version + ".wrap");
     Packager.NewWithDescriptor(file, name, version, content, descriptorLines);
     return file;
 }
 public TestMemoryFile(string filePath, int lines)
 {
     this.lines = lines;
     wrapped = new InMemoryFile(filePath);
     WriteContent();
 }
示例#8
0
 public InMemFileStream(InMemoryFile file, FileAccess fileAccess)
 {
     _file = file;
     _fileAccess = fileAccess;
 }
示例#9
0
 void CopyFromFile(InMemoryFile fileToCopy)
 {
     Exists = true;
     LastModifiedTimeUtc = fileToCopy.LastModifiedTimeUtc;
     lock (fileToCopy._contentLock)
     {
         var newContent = new byte[fileToCopy._content.Length];
         Buffer.BlockCopy(fileToCopy._content, 0, newContent, 0, fileToCopy._content.Length);
         _content = newContent;
         _contentLength = fileToCopy._contentLength;
     }
 }