Open() public static method

public static Open ( string file, XRefArchiveMode mode ) : XRefArchive
file string
mode XRefArchiveMode
return XRefArchive
Ejemplo n.º 1
0
 public async Task <bool> DownloadAsync(Uri uri, string outputFile)
 {
     if (uri == null)
     {
         throw new ArgumentNullException(nameof(uri));
     }
     if (!uri.IsAbsoluteUri)
     {
         throw new ArgumentException("Relative path is not allowed.", nameof(uri));
     }
     using (new LoggerPhaseScope(PhaseName))
         using (new LoggerFileScope(outputFile))
         {
             Logger.LogInfo($"Creating xref archive file...");
             try
             {
                 using (var xa = XRefArchive.Open(outputFile, XRefArchiveMode.Create))
                 {
                     await DownloadCoreAsync(uri, xa, true);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError($"Unable to create archive: {ex.Message}");
                 return(false);
             }
             Logger.LogInfo($"Xref archive file created.");
             return(true);
         }
 }
Ejemplo n.º 2
0
        private static IXRefContainer ReadLocalFile(string filePath)
        {
            if (".zip".Equals(Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase))
            {
                return(XRefArchive.Open(filePath, XRefArchiveMode.Read));
            }

            using var sr = File.OpenText(filePath);
            return(YamlUtility.Deserialize <XRefMap>(sr));
        }
Ejemplo n.º 3
0
        protected static IXRefContainer DownloadFromLocal(Uri uri)
        {
            var filePath = uri.LocalPath;

            if (".zip".Equals(Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase))
            {
                return(XRefArchive.Open(filePath, XRefArchiveMode.Read));
            }
            using (var sr = File.OpenText(filePath))
            {
                return(YamlUtility.Deserialize <XRefMap>(sr));
            }
        }