/// <summary> /// Create intersection with another option /// </summary> /// <param name="option"></param> /// <returns>this if <paramref name="option"/> is null or new instance with intersection</returns> public virtual AllOptions Intersection(IOption option) { if (option == null) { return(this); } AllOptions result = new AllOptions(); result.CanBrowse = this.CanBrowse | option.CanBrowse(); result.CanGetEntry = this.CanGetEntry | option.CanGetEntry(); result.CanObserve = this.CanObserve | option.CanObserve(); result.CanOpen = this.CanOpen | option.CanOpen(); result.CanRead = this.CanRead | option.CanRead(); result.CanWrite = this.CanWrite | option.CanWrite(); result.CanCreateFile = this.CanCreateFile | option.CanCreateFile(); result.CanDelete = this.CanDelete | option.CanDelete(); result.CanSetFileAttribute = this.CanSetFileAttribute | option.CanSetFileAttribute(); result.CanMount = this.CanMount | option.CanMount(); result.CanCreateFile = this.CanCreateFile | option.CanCreateFile(); result.CanDelete = this.CanDelete | option.CanDelete(); result.CanMove = this.CanMove | option.CanMove(); result.CanCreateDirectory = this.CanCreateDirectory | option.CanCreateDirectory(); result.CanMount = this.CanMount | option.CanMount(); result.CanUnmount = this.CanUnmount | option.CanUnmount(); result.CanListMountPoints = this.CanListMountPoints | option.CanListMountPoints(); result.SubPath = this.SubPath ?? option.SubPath(); return(result); }
/// <summary> /// Read options from <paramref name="option"/> and return flattened object. /// </summary> /// <param name="option"></param> /// <returns></returns> public static AllOptions Read(IOption option) { AllOptions result = new AllOptions(); result.ReadFrom(option); return(result); }
/// <summary> /// Create adapter that adapts <paramref name="sourceFilesystem"/> into <see cref="IFileProvider"/>. /// </summary> /// <param name="sourceFilesystem"></param> /// <param name="option">(optional) decorating options, such as <see cref="IToken"/></param> public FileSystemProvider(IFileSystem sourceFilesystem, IOption option = null) : base() { FileSystem = sourceFilesystem ?? throw new ArgumentNullException(nameof(sourceFilesystem)); this.options = AllOptions.Read(Option.Union(sourceFilesystem, option)); this.token = option.AsOption <IToken>(); }