本文整理汇总了C#中System.Data.SQLite.SQLiteConnectionStringBuilder.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnectionStringBuilder.ContainsKey方法的具体用法?C# SQLiteConnectionStringBuilder.ContainsKey怎么用?C# SQLiteConnectionStringBuilder.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.SQLite.SQLiteConnectionStringBuilder
的用法示例。
在下文中一共展示了SQLiteConnectionStringBuilder.ContainsKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public override void Open()
{
VerifyNotDisposed();
if (State != ConnectionState.Closed)
throw new InvalidOperationException("Cannot Open when State is {0}.".FormatInvariant(State));
var connectionStringBuilder = new SQLiteConnectionStringBuilder { ConnectionString = ConnectionString };
m_dataSource = connectionStringBuilder.DataSource;
if (string.IsNullOrEmpty(m_dataSource))
throw new InvalidOperationException("Connection String Data Source must be set.");
SQLiteOpenFlags openFlags = connectionStringBuilder.ReadOnly ? SQLiteOpenFlags.ReadOnly : SQLiteOpenFlags.ReadWrite;
if (!connectionStringBuilder.FailIfMissing && !connectionStringBuilder.ReadOnly)
openFlags |= SQLiteOpenFlags.Create;
SetState(ConnectionState.Connecting);
Match m = s_vfsRegex.Match(m_dataSource);
string fileName = m.Groups["fileName"].Value;
string vfsName = m.Groups["vfsName"].Value;
var errorCode = NativeMethods.sqlite3_open_v2(ToNullTerminatedUtf8(fileName), out m_db, openFlags, string.IsNullOrEmpty(vfsName) ? null : ToNullTerminatedUtf8(vfsName));
bool success = false;
try
{
if (errorCode != SQLiteErrorCode.Ok)
{
SetState(ConnectionState.Broken);
errorCode.ThrowOnError();
}
if (!string.IsNullOrEmpty(connectionStringBuilder.Password))
{
byte[] passwordBytes = Encoding.UTF8.GetBytes(connectionStringBuilder.Password);
NativeMethods.sqlite3_key(m_db, passwordBytes, passwordBytes.Length).ThrowOnError();
}
bool allowOpenReadOnly = true;
#if MONOANDROID
// opening read-only throws "EntryPointNotFoundException: sqlite3_db_readonly" on Android API 15 and below (JellyBean is API 16)
allowOpenReadOnly = Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.JellyBean;
#endif
if (allowOpenReadOnly)
{
int isReadOnly = NativeMethods.sqlite3_db_readonly(m_db, "main");
if (isReadOnly == 1 && !connectionStringBuilder.ReadOnly)
throw new SQLiteException(SQLiteErrorCode.ReadOnly);
}
if (connectionStringBuilder.CacheSize != 0)
this.ExecuteNonQuery("pragma cache_size={0}".FormatInvariant(connectionStringBuilder.CacheSize));
if (connectionStringBuilder.PageSize != 0)
this.ExecuteNonQuery("pragma page_size={0}".FormatInvariant(connectionStringBuilder.PageSize));
if (connectionStringBuilder.ContainsKey(SQLiteConnectionStringBuilder.MmapSizeKey))
this.ExecuteNonQuery("pragma mmap_size={0}".FormatInvariant(connectionStringBuilder.MmapSize));
if (connectionStringBuilder.ForeignKeys)
this.ExecuteNonQuery("pragma foreign_keys = on");
if (connectionStringBuilder.JournalMode != SQLiteJournalModeEnum.Default)
this.ExecuteNonQuery("pragma journal_mode={0}".FormatInvariant(connectionStringBuilder.JournalMode));
if (connectionStringBuilder.ContainsKey(SQLiteConnectionStringBuilder.SynchronousKey))
this.ExecuteNonQuery("pragma synchronous={0}".FormatInvariant(connectionStringBuilder.SyncMode));
if (connectionStringBuilder.TempStore != SQLiteTemporaryStore.Default)
this.ExecuteNonQuery("pragma temp_store={0}".FormatInvariant(connectionStringBuilder.TempStore));
if (m_statementCompleted != null)
SetProfileCallback(s_profileCallback);
SetState(ConnectionState.Open);
success = true;
}
finally
{
if (!success)
Utility.Dispose(ref m_db);
}
}