当前位置: 首页>>代码示例>>C#>>正文


C# ConnectionString.GetValue方法代码示例

本文整理汇总了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));
        }
开发者ID:ChrisCross67,项目名称:LiteDB,代码行数:14,代码来源:LiteDatabase.cs

示例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");
        }
开发者ID:sovanesyan,项目名称:Burrow.NET,代码行数:8,代码来源:MethodGetValue.cs

示例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);
        }
开发者ID:AshishVishwakarma,项目名称:LiteDB,代码行数:11,代码来源:EncryptedDiskService.cs

示例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);
        }
开发者ID:sovanesyan,项目名称:Burrow.NET,代码行数:11,代码来源:MethodGetValue.cs

示例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);
        }
开发者ID:apkd,项目名称:LiteDB,代码行数:11,代码来源:EncryptedDiskService.cs

示例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);
        }
开发者ID:kangkot,项目名称:Burrow.NET,代码行数:11,代码来源:MethodGetValue.cs

示例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));
        }
开发者ID:ktaranov,项目名称:LiteDB,代码行数:27,代码来源:FileDiskService.cs

示例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");
 }
开发者ID:kangkot,项目名称:Burrow.NET,代码行数:5,代码来源:MethodGetValue.cs

示例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);
 }
开发者ID:kangkot,项目名称:Burrow.NET,代码行数:5,代码来源:MethodGetValue.cs


注:本文中的ConnectionString.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。