コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 protected void when_publishing_package(InMemoryFile package)
 {
     using (var stream = package.OpenRead())
     using(var publisher = Repository.Publisher())
         publisher.Publish(package.Name, stream);
 }
コード例 #4
0
 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
ファイル: assembly_resolving.cs プロジェクト: QMTech/openwrap
 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;
 }
コード例 #7
0
 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;
     }
 }