示例#1
0
 static ZipArchiveStorage LoadZip(Byte[] fileBytes)
 {
     try
     {
         return(ZipArchiveStorage.Parse(fileBytes));
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#2
0
 /// <summary>
 /// Test model archiver
 /// </summary>
 private static async Task TestOpcUaModelArchiveAsync(EndpointModel endpoint)
 {
     using (var logger = StackLogger.Create(ConsoleLogger.Create())) {
         var storage  = new ZipArchiveStorage();
         var fileName = "tmp.zip";
         using (var client = new ClientServices(logger.Logger, new TestClientServicesConfig()))
             using (var server = new ServerWrapper(endpoint, logger)) {
                 var sw = Stopwatch.StartNew();
                 using (var archive = await storage.OpenAsync(fileName, FileMode.Create, FileAccess.Write))
                     using (var archiver = new AddressSpaceArchiver(client, endpoint, archive, logger.Logger)) {
                         await archiver.ArchiveAsync(CancellationToken.None);
                     }
                 var elapsed = sw.Elapsed;
                 using (var file = File.Open(fileName, FileMode.OpenOrCreate)) {
                     Console.WriteLine($"Encode as to {fileName} took " +
                                       $"{elapsed}, and produced {file.Length} bytes.");
                 }
             }
     }
 }