/// <summary> /// Establishes the connection and initializes internal structures /// </summary> /// <param name="arg">Settings for the connection, model etc</param> /// <param name="policy">Policy for this datamanager</param> public DataManagerWithPolicy(ConnectionParameters arg, ExecutionPolicy policy) { Contract.Requires(!string.IsNullOrEmpty(arg.connection)); Contract.Requires(!string.IsNullOrEmpty(arg.modelResource)); KConnectionParameters = arg; KPolicy = policy; _creator = new CreationStrategy(KConnectionParameters, KPolicy); switch (KPolicy.PeriodicDisposalStrategy) { case Strategy.DisposeWithThread: _cleaner = new RemoveOnlyWhenThreadIsDead(_map, KPolicy); break; case Strategy.DisposeWhenNotInUse: _cleaner = new RemoveUnused(_map, KPolicy); break; case Strategy.DisposeLeastRecentlyUsed: _cleaner = new RemoveLeastRecentlyUsed(_map, KPolicy); break; default: this._cleaner = new CleaningStrategy(_map, KPolicy); break; } _cleaner.Start(); }
private static void AddStrategyToConfig(string name, ICleaningStrategy strategy) { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.Sections.Add("DatabaseCleaner", new DatabaseCleanerSection()); DatabaseCleanerSection section = (DatabaseCleanerSection)config.GetSection("DatabaseCleaner"); section.Strategies.Add(new StrategyElement(name, strategy.GetType().AssemblyQualifiedName)); config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("DatabaseCleaner"); }
public void SetCleaningStrategy(ICleaningStrategy cs) { _cs = cs; }