/// <summary> /// Create a new CifsConnectionManager and cache it to reuse next time it is called with the same FileStorageSetting. /// Avoid to create a new FileStorageSetting /// </summary> /// <param name="fss">FileStorageSetting</param> /// <param name="log"></param> /// <returns></returns> public static CifsConnectionManager GetOrCreate(FileStorageSetting fss, ILogger log = null) { if (fss == null) { return(null); } if (cache.ContainsKey(fss)) { return(cache[fss]); } var v = new CifsConnectionManager(fss, log); cache[fss] = v; return(v); }
public CifsConnectionManager(FileStorageSetting cf, ILogger log = null) { if (cf is null) { throw new ArgumentNullException(nameof(cf)); } Log = log; Config = cf; var networkCredential = string.IsNullOrEmpty(cf?.Domain) ? new NetworkCredential(cf.Login, cf.Password) : new NetworkCredential(cf.Login, cf.Password, cf.Domain); network = new NetworkConnection(cf.RemoteLocation, networkCredential, log); }