public static async Task <PackageContainerLocalFile> CreateAndLoadAsync( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerBase takeOver = null, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { var res = new PackageContainerLocalFile( CopyMode.Serialized, takeOver, packageCentral, location, containerOptions); if (overrideLoadResident || true == res.ContainerOptions?.LoadResident) { await res.LoadFromSourceAsync(fullItemLocation, runtimeOptions); } return(res); }
public static async Task <PackageContainerBase> GuessAndCreateForAsync( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerBase takeOver = null, PackageContainerListBase containerList = null, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { // access if (location == null) { return(null); } var ll = location.ToLower(); // guess runtimeOptions?.Log?.Info($"Trying to guess package container for {location} .."); var guess = PackageContainerGuess.FromLocation(location, runtimeOptions); if (guess == null) { runtimeOptions?.Log?.Info("Aborting"); return(null); } // start runtimeOptions?.Log?.Info($".. with containerOptions = {containerOptions?.ToString()}"); // TODO (MIHO, 2021-02-01): check, if demo option is still required if (ll.Contains("/demo")) { return(await Demo(packageCentral, location, overrideLoadResident, containerOptions, runtimeOptions)); } // starts with http ? if (guess.GuessedType == typeof(PackageContainerNetworkHttpFile)) { var cnt = await PackageContainerNetworkHttpFile.CreateAndLoadAsync( packageCentral, location, fullItemLocation, overrideLoadResident, takeOver, containerList, containerOptions, runtimeOptions); if (cnt.ContainerOptions.StayConnected && guess.AasId.HasContent() && guess.HeadOfPath.HasContent()) { cnt.ConnectorPrimary = new PackageConnectorHttpRest(cnt, new Uri(guess.HeadOfPath + "/aas/" + guess.AasId)); } return(cnt); } // check FileInfo for (possible?) local file FileInfo fi = null; try { fi = new FileInfo(location); } catch (Exception ex) { LogInternally.That.SilentlyIgnoredError(ex); } // if file, try to open (might throw exceptions!) if (fi != null) { // seems to be a valid (possible) file return(await PackageContainerLocalFile.CreateAndLoadAsync( packageCentral, location, fullItemLocation, overrideLoadResident, takeOver, containerOptions)); } // no?? runtimeOptions?.Log?.Info($".. no any possible option for package container found .. Aborting!"); return(null); }