コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SambaFileSystem"/> class
        /// from values in application settings.
        /// </summary>
        /// <param name="alias">The alias of the provider</param>
        public SambaFileSystem(string alias)
        {
            var fullPath = ConfigurationManager.AppSettings[$"{Constants.WebConfiguration.FullPathKey}:{alias}"];

            if (string.IsNullOrWhiteSpace(fullPath))
            {
                throw new InvalidOperationException($"Full path is not defined in application settings. The {Constants.WebConfiguration.FullPathKey} property was not defined or is empty.");
            }

            var rootUrl = ConfigurationManager.AppSettings[$"{Constants.WebConfiguration.RootUrlKey}:{alias}"];

            var connectionString = ConfigurationManager.AppSettings[$"{Constants.WebConfiguration.ConnectionStringKey}:{alias}"];

            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new InvalidOperationException($"Samba connection string is not defined in application settings. The {Constants.WebConfiguration.ConnectionStringKey} property was not defined or is empty.");
            }

            var maxDaysStr = ConfigurationManager.AppSettings[$"{Constants.WebConfiguration.MaxDaysKey}:{alias}"];
            var maxDays    = string.IsNullOrEmpty(maxDaysStr) ? Constants.DefaultMaxDays : int.Parse(maxDaysStr);

            var virtualPathRoute = ConfigurationManager.AppSettings[$"{Constants.WebConfiguration.VirtualPathRouteKey}:{alias}"];

            this.FileSystem = SambaServiceDriver.GetInstance(fullPath, rootUrl, connectionString, maxDays, virtualPathRoute);
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SambaFileSystem"/> class.
 /// </summary>
 /// <param name="fullPath">The working full path.</param>
 /// <param name="rootUrl">The root url.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param>
 /// <param name="virtualPathRoute">When defined, Whether to use the default "media" route in the url independent of the blob container.</param>
 public SambaFileSystem(string fullPath, string rootUrl, string connectionString, string maxDays, string virtualPathRoute)
 {
     this.FileSystem = SambaServiceDriver.GetInstance(fullPath, rootUrl, connectionString, int.Parse(maxDays, CultureInfo.InvariantCulture), virtualPathRoute);
 }