本文整理汇总了C#中ConnectionString.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# ConnectionString.GetValue方法的具体用法?C# ConnectionString.GetValue怎么用?C# ConnectionString.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionString
的用法示例。
在下文中一共展示了ConnectionString.GetValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiteDatabase
/// <summary>
/// Starts LiteDB database using a connection string for filesystem database
/// </summary>
public LiteDatabase(string connectionString)
{
var conn = new ConnectionString(connectionString);
var version = conn.GetValue<ushort>("version", 0);
var encrypted = !StringExtensions.IsNullOrWhiteSpace(conn.GetValue<string>("password", null));
_engine = new LazyLoad<DbEngine>(
() => new DbEngine(encrypted ? new EncryptedDiskService(conn, _log) : new FileDiskService(conn, _log), _log),
() => this.InitializeMapper(),
() => this.UpdateDbVersion(version));
}
示例2: Should_throw_exception_if_try_to_get_value_not_in_connectionstring
public void Should_throw_exception_if_try_to_get_value_not_in_connectionstring()
{
// Arrange
var con = new ConnectionString("host=localhost;username=guest;password=guest");
// Action
var port = con.GetValue("port");
}
示例3: EncryptedDiskService
public EncryptedDiskService(ConnectionString conn, Logger log)
: base(conn, log)
{
// initialize AES with passoword
var password = conn.GetValue<string>("password", null);
// hash password to store in header to check
_password = SimpleAES.HashSHA1(password);
_crypto = new SimpleAES(password);
}
示例4: Should_return_value_provided_in_connectionstring
public void Should_return_value_provided_in_connectionstring()
{
// Arrange
var con = new ConnectionString("host=localhost;username=guest;password=guest");
// Action
var host = con.GetValue("host");
// Assert
Assert.AreEqual("localhost", host);
}
示例5: EncryptedDiskService
public EncryptedDiskService(ConnectionString conn, Logger log)
: base(conn, log)
{
// initialize AES with passoword
var password = conn.GetValue<string>("password", null);
// hash password to store in header to check if password is correct
_crypto = LitePlatform.Platform.GetEncryption(password);
_password = _crypto.HashSHA1(password);
}
示例6: Should_return_value_provided_in_connectionstring_using_caseinsensitive_key
public void Should_return_value_provided_in_connectionstring_using_caseinsensitive_key()
{
// Arrange
var con = new ConnectionString("host=localhost;virtualHost=UAT;username=guest;password=guest");
// Action
var virtualHost = con.GetValue("virtualhost");
// Assert
Assert.AreEqual("UAT", virtualHost);
}
示例7: 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));
}
示例8: When_get_with_default_value_should_throw_exception_if_provided_key_is_null
public void When_get_with_default_value_should_throw_exception_if_provided_key_is_null()
{
var con = new ConnectionString("host=localhost:5673;username=guest;password=guest");
con.GetValue(null, "ABC");
}
示例9: Should_throw_exception_if_provided_key_is_null
public void Should_throw_exception_if_provided_key_is_null()
{
var con = new ConnectionString("host=localhost:5673;username=guest;password=guest");
con.GetValue(null);
}