protected XDocument LoadFile(PackagesConfigOptions options) { if (!System.IO.File.Exists(file)) { if (!options.HasFlag(PackagesConfigOptions.LoadOrNew)) { throw new FileNotFoundException(nameof(file)); } return(NewStorage()); } if (!options.HasFlag(PackagesConfigOptions.SilentLoading)) { return(XDocument.Load(file)); } try { return(XDocument.Load(file)); } catch (Exception ex) { FailedLoading = ex; return(NewStorage()); } }
/// <param name="path">The path to the directory where the config is located (or must be located if new).</param> /// <param name="options">Configure initialization using <see cref="PackagesConfigOptions"/>.</param> public PackagesConfig(string path, PackagesConfigOptions options = PackagesConfigOptions.Default) { if (path == null) { throw new ArgumentNullException(nameof(path)); } file = options.HasFlag(PackagesConfigOptions.PathToStorage) ? path : Path.Combine(path, FNAME); if ((options & (PackagesConfigOptions.Load | PackagesConfigOptions.LoadOrNew)) == 0) { throw new NotSupportedException(); } xml = Load(options); }