本文整理汇总了C#中ConnectionString.GetFileSize方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionString.GetFileSize方法的具体用法?C# ConnectionString.GetFileSize怎么用?C# ConnectionString.GetFileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionString
的用法示例。
在下文中一共展示了ConnectionString.GetFileSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FileDiskService
public FileDiskService(string connectionString, Logger log)
{
var str = new ConnectionString(connectionString);
_filename = str.GetValue<string>("filename", "");
var journalEnabled = str.GetValue<bool>("journal", true);
_timeout = str.GetValue<TimeSpan>("timeout", new TimeSpan(0, 1, 0));
_readonly = str.GetValue<bool>("readonly", false);
_password = str.GetValue<string>("password", null);
_initialSize = str.GetFileSize("initial size", 0);
_limitSize = str.GetFileSize("limit size", 0);
var level = str.GetValue<byte?>("log", null);
// simple validations
if (string.IsNullOrWhiteSpace(_filename)) throw new ArgumentNullException("filename");
if (_initialSize > 0 && _initialSize < (BasePage.PAGE_SIZE * 10)) throw new ArgumentException("initial size too low");
if (_limitSize > 0 && _limitSize < (BasePage.PAGE_SIZE * 10)) throw new ArgumentException("limit size too low");
if (_initialSize > 0 && _limitSize > 0 && _initialSize > _limitSize) throw new ArgumentException("limit size less than initial size");
// setup log + log-level
_log = log;
if(level.HasValue) _log.Level = level.Value;
_journalEnabled = _readonly ? false : journalEnabled; // readonly? no journal
_journalFilename = Path.Combine(Path.GetDirectoryName(_filename), Path.GetFileNameWithoutExtension(_filename) + "-journal" + Path.GetExtension(_filename));
_tempFilename = Path.Combine(Path.GetDirectoryName(_filename), Path.GetFileNameWithoutExtension(_filename) + "-temp" + Path.GetExtension(_filename));
}