public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "EucalyptoWikiProvider"; base.Initialize(name, config); this.mProviderName = name; //Read the configurations //Connection string string connName = ExtractConfigValue(config, "connectionStringName", null); mConfiguration = ConfigurationHelper.Create(connName); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) throw new System.Configuration.Provider.ProviderException("Unrecognized attribute: " + attr); } }
/// <summary> /// Creates an instance of GenericGenerator Class using a custom ConnectionParameters config /// </summary> /// <param name="config"></param> public GenericGenerator(ConnectionParameters config) { _Configuration = config; LoadAssembliesMappings(); }
/// <summary> /// This method first look if there is already a saved configuration in the cached list. /// If not exist try to check if there is a connection string in the config file with the same name. /// If not exist throw an exception. /// </summary> /// <param name="connectionString">The name of the connection string to use or a custom connection name. /// To use custom connection use the AddCachedConfiguration method to configure it, otherwise a new configuration is automatically created.</param> private IConnectionParameters CreateFromConnectionString(ConnectionStringSettings connectionString) { if (connectionString != null && !string.IsNullOrEmpty(connectionString.Name)) { lock (mList) { ConnectionParameters savedConfig; if (mList.TryGetValue(connectionString.Name, out savedConfig)) return savedConfig; } if (!String.IsNullOrEmpty(connectionString.ConnectionString)) { var configuration = new ConnectionParameters(connectionString.Name); configuration.ReadConnectionParameters(connectionString); return AddCachedConfiguration(configuration, false); } } throw new ConfigurationNotFoundException("Name"); }
/// <summary> /// Add the specified configuration to the list of saved configuration. /// </summary> /// <param name="configuration"></param> /// <param name="throwErrorIfExists">True to throw an exception if there is already a connection with the same name, otherwise if a connection already exist this method simply return the previous connection.</param> /// <returns>Return the connection just added or the previous connection is there is already a connection with the same name.</returns> private IConnectionParameters AddCachedConfiguration(ConnectionParameters configuration, bool throwErrorIfExists) { lock (mList) { ConnectionParameters savedConfig; if (mList.TryGetValue(configuration.Name, out savedConfig)) { if (throwErrorIfExists) throw new ConfigurationAlreadyExistsException(configuration.Name); return savedConfig; } mList.Add(configuration.Name, configuration); return configuration; } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "EucalyptoRoleProvider"; base.Initialize(name, config); this.mProviderName = name; this.mApplicationName = ExtractConfigValue(config, "applicationName", ConnectionParameters.DEFAULT_APP); //System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath string connName = ExtractConfigValue(config, "connectionStringName", null); mConfiguration = ConfigurationHelper.Create(connName); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) throw new System.Configuration.Provider.ProviderException("Unrecognized attribute: " + attr); } }
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "EucalyptoMembershipProvider"; base.Initialize(name, config); this.mProviderName = name; this.mApplicationName = ExtractConfigValue(config, "applicationName", ConnectionParameters.DEFAULT_APP); //System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath this.mEnablePasswordReset = bool.Parse(ExtractConfigValue(config, "enablePasswordReset", "true")); this.mEnablePasswordRetrieval = false; //bool.Parse(GetConfigValue(config["enablePasswordRetrieval"], "false")); this.mMaxInvalidPasswordAttempts = int.Parse(ExtractConfigValue(config, "maxInvalidPasswordAttempts", "5")); this.mMinRequiredNonAlphanumericCharacters = int.Parse(ExtractConfigValue(config, "minRequiredNonAlphanumericCharacters", "1")); this.mMinRequiredPasswordLength = int.Parse(ExtractConfigValue(config, "minRequiredPasswordLength", "7")); this.mPasswordAttemptWindow = int.Parse(ExtractConfigValue(config, "passwordAttemptWindow", "10")); this.mPasswordFormat = MembershipPasswordFormat.Hashed; //Enum.Parse(typeof(MembershipPasswordFormat), GetConfigValue(config["passwordFormat"], "Hashed")); this.mPasswordStrengthRegularExpression = ExtractConfigValue(config, "passwordStrengthRegularExpression", ""); this.mRequiresQuestionAndAnswer = bool.Parse(ExtractConfigValue(config, "requiresQuestionAndAnswer", "false")); this.mRequiresUniqueEmail = bool.Parse(ExtractConfigValue(config, "requiresUniqueEmail", "true")); string connName = ExtractConfigValue(config, "connectionStringName", null); mConfiguration = ConfigurationHelper.Create(connName); // Throw an exception if unrecognized attributes remain if (config.Count > 0) { string attr = config.GetKey(0); if (!String.IsNullOrEmpty(attr)) throw new System.Configuration.Provider.ProviderException("Unrecognized attribute: " + attr); } }
/// <summary> /// Create a new transaction scope with a new session and a new transaction. /// The session and transaction are created based on the ConnectionParameters class. /// Both objects are disposed at the end. /// </summary> /// <param name="configuration"></param> public TransactionScope(ConnectionParameters configuration) { NHibernateSession = configuration.OpenSession(); NHibernateTransaction = NHibernateSession.BeginTransaction(); _dispose = true; }