/// <summary> /// Allows settings to be stored in the UsersSessionMemory, /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="hint">The persistance hint.</param> public virtual void Set(object key, object value, PersistHint hint) { if (key == null) { Trace.TraceError("The key cannot be null in the UserMemory Set method."); throw new InvalidOperationException( "The Set method in the UserMemory provider does not allow the key property to be null."); } if (value == null) { Trace.TraceError("The key [{0}] cannot have its value set to null.", key); throw new InvalidOperationException( "The Set method in the UserMemory provider does not allow the value property to be null."); } InternalSetBegin(key, value); if (_usersSessionMemory.ContainsKey(key)) { _usersSessionMemory[key] = value; } else { _usersSessionMemory.Add(key, value); } }
/// <summary> /// Allows settings to be stored in the UsersSessionMemory, /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="hint">The persistance hint.</param> public override void Set(object key, object value, PersistHint hint) { base.Set(key, value, hint); if (hint != PersistHint.None) { SaveAll(); } }
/// <summary> /// Allows a set on settings /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="hint">The persistance hint.</param> public override void Set(object key, object value, PersistHint hint) { base.Set(key, value, hint); if (hint == PersistHint.AcrossSessions) { byte[] buffer = SerializeObject(value); using (SqlConnection connection = new SqlConnection(_connectionSettings.ConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(writeStatement, connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("@SettingKey", key); command.Parameters.AddWithValue("@UserId", Engine.IdentityProvider.Principal.Identity.Name); command.Parameters.AddWithValue("@SettingValue", buffer); command.ExecuteNonQuery(); } } }
/// <summary> /// Allows a set on settings /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <param name="hint">The persistance hint.</param> public override void Set(object key, object value, PersistHint hint) { base.Set(key, value, hint); if (hint == PersistHint.AcrossSessions) { byte[] buffer = SerializeObject(value); using (SqlConnection connection = new SqlConnection(_connectionSettings.ConnectionString)) { connection.Open(); SqlCommand command = new SqlCommand(writeStatement, connection) { CommandType = System.Data.CommandType.StoredProcedure }; command.Parameters.AddWithValue("@SettingKey", key); command.Parameters.AddWithValue("@UserId", Engine.IdentityProvider.Principal.Identity.Name); command.Parameters.AddWithValue("@SettingValue", buffer); command.ExecuteNonQuery(); } } }