private static int provisionCollection(string collectionName, IDictionary <string, string> searchFields, IDictionary <string, string> additionalSearchFields, string username, string password, bool dropFirst) { // if no username set, use the default if (String.IsNullOrEmpty(username)) { username = JSONStoreConstants.JSON_STORE_DEFAULT_USER; } // get the shared manager JSONStoreSQLLite store = JSONStoreSQLLite.sharedManager(username); if (store == null) { //JSONStoreLoggerError(@"Error: JSON_STORE_USERNAME_MISMATCH, code: %d, username passed: %@, accessor username: %@, collection name: %@", JSON_STORE_USERNAME_MISMATCH, username, accessor != nil ? accessor.username : @"nil", collectionName); throw new JSONStoreException(JSONStoreConstants.JSON_STORE_USERNAME_MISMATCH); } if (!String.IsNullOrEmpty(password)) { // set the key for the database lock (lockThis) { if (!store.setDatabaseKey(username, password)) { //JSONStoreLoggerError(@"Error: JSON_STORE_PROVISION_KEY_FAILURE, code: %d, checkForSecurityUpgrade return code: %d, setDBKeyWorked: %@", JSON_STORE_PROVISION_KEY_FAILURE, rc, setDBKeyWorked ? @"YES" : @"NO"); throw new JSONStoreException(JSONStoreConstants.JSON_STORE_PROVISION_KEY_FAILURE); } } } int rc = 0; lock (lockThis) { // drop the table if needed if (dropFirst) { store.dropTable(collectionName); } // provision the collection for the name, searchFields, and additionalSearchFields rc = store.provisionCollection(collectionName, new JSONStoreSchema(searchFields, additionalSearchFields)); if (rc < JSONStoreConstants.JSON_STORE_RC_OK) { //JSONStoreLoggerError(@"Error: JSON_STORE_EXCEPTION, code: %d, username: %@, accessor username: %@, collection name: %@, searchFields: %@, additionalSearchFields: %@", rc, username, accessor != nil ? accessor.username : @"nil", collectionName, searchFields, additionalIndexes); store.close(); throw new JSONStoreException(rc); } } return(rc); }