private static void GenerateManifest(Parameters Params, IDictionary <string, DependencyFile> DepFiles, IDictionary <string, DependencyBlob> DepBlobs, IDictionary <string, DependencyPack> DepPacks) { DependencyManifest Manifest = new DependencyManifest(); IDictionary <string, DependencyFile> Files = new SortedDictionary <string, DependencyFile>(); IDictionary <string, DependencyBlob> Blobs = new SortedDictionary <string, DependencyBlob>(); IDictionary <string, DependencyPack> Packs = new SortedDictionary <string, DependencyPack>(); foreach (DependencyFile DepFile in DepFiles.Values) { Files.Add(DepFile.Name, DepFile); DependencyBlob DepBlob = DepBlobs[DepFile.Hash]; if (!Blobs.ContainsKey(DepBlob.Hash)) { Blobs.Add(DepBlob.Hash, DepBlob); DependencyPack DepPack = DepPacks[DepBlob.PackHash]; if (!Packs.ContainsKey(DepPack.Hash)) { Packs.Add(DepPack.Hash, DepPack); } } } Manifest.BaseUrl = Params.BaseUrl; Manifest.IgnoreProxy = Params.IgnoreProxy; Manifest.Files = Files.Values.ToArray(); Manifest.Blobs = Blobs.Values.ToArray(); Manifest.Packs = Packs.Values.ToArray(); WriteXmlObject(Params.Target, Manifest); }
public void Ctor_Test() { DependencyPack pack = new DependencyPack(); IServiceCollection services = new ServiceCollection(); services = pack.AddServices(services); }
public void Ignore_Test() { IServiceCollection services = new ServiceCollection(); DependencyPack pack = new DependencyPack(); services = pack.AddServices(services); services.ShouldContain(m => m.ServiceType == typeof(ITestContract)); services.ShouldNotContain(m => m.ServiceType == typeof(IIgnoreContract)); }
private static void GeneratePackFilesThread(Parameters Params, ConcurrentQueue <DependencyBlob> BlobsQueue, IDictionary <string, string> BlobToFile, ConcurrentDictionary <string, DependencyPack> DepPacks) { while (true) { DependencyBlob DepBlob; if (!BlobsQueue.TryDequeue(out DepBlob)) { return; } String TempPath = Path.Combine(Params.Storage, "." + Guid.NewGuid().ToString() + ".tmp"); try { List <DependencyBlob> PackedBlobs = new List <DependencyBlob>(); DependencyPack DepPack = new DependencyPack(); using (FileStream Stream = File.Create(TempPath)) { SHA1Managed Hasher = new SHA1Managed(); using (GZipStream GZip = new GZipStream(Stream, CompressionMode.Compress, true)) { CryptoStream HashStream = new CryptoStream(GZip, Hasher, CryptoStreamMode.Write); Stream PackStream = new WriteStream(HashStream); PackStream.Write(Signature, 0, Signature.Length); while (true) { PackedBlobs.Add(DepBlob); DepBlob.PackOffset = PackStream.Position; using (FileStream BlobFile = File.Open(BlobToFile[DepBlob.Hash], FileMode.Open, FileAccess.Read, FileShare.Read)) { Log.WriteLine("Copying file: {0}", BlobToFile[DepBlob.Hash]); BlobFile.CopyTo(PackStream); } if ((Stream.Position > Params.Optimal) || (!BlobsQueue.TryDequeue(out DepBlob))) { break; } } DepPack.Size = PackStream.Position; HashStream.FlushFinalBlock(); } DepPack.Hash = BitConverter.ToString(Hasher.Hash).ToLower().Replace("-", ""); DepPack.CompressedSize = Stream.Position; } string PackFile = Path.Combine(Params.Storage, DepPack.Hash); if (!File.Exists(PackFile)) { Log.WriteLine("Moving File: {0}", PackFile); File.Move(TempPath, PackFile); } foreach (DependencyBlob Blob in PackedBlobs) { Blob.PackHash = DepPack.Hash; } DepPack.RemotePath = Params.RemotePath; DepPacks.TryAdd(DepPack.Hash, DepPack); } finally { if (File.Exists(TempPath)) { File.Delete(TempPath); } } } }