public Application() { string prevalenceBase = Path.Combine(Environment.CurrentDirectory, "data"); _engine = PrevalenceActivator.CreateTransparentEngine(typeof(ToDoList), prevalenceBase); _system = _engine.PrevalentSystem as ToDoList; }
/// <summary> /// Returns a list with all the files in the PrevalenceBase /// folder sorted by name. /// </summary> /// <param name="engine">the prevalence engine</param> /// <returns>list of files sorted by name</returns> public static FileInfo[] GetPrevalenceFilesSortedByName(PrevalenceEngine engine) { DirectoryInfo prevalenceBase = engine.PrevalenceBase; FileInfo[] files = prevalenceBase.GetFiles("*.*"); SortFilesByName(files); return files; }
public SnapshotTaker(PrevalenceEngine engine, double interval) { _engine = engine; _timer = new Timer(interval); _timer.AutoReset = true; _timer.Elapsed += new ElapsedEventHandler(Elapsed); _timer.Start(); }
public ProjectController( PestControlModel model, PrevalenceEngine engine, SourceControlManager scm, BuildSystemManager bsm) { _engine = engine; _model = model; _scm = scm; _bsm = bsm; }
public void SetUp() { // O primeiro passo � limpar qualquer resqu�cio de // testes anteriores para come�ar com uma "base" limpa ClearPrevalenceBase(); _engine = PrevalenceActivator.CreateEngine(typeof(TaskManagementSystem), PrevalenceBase); _system = _engine.PrevalentSystem as TaskManagementSystem; }
private void CreateSnapshotTaker(PrevalenceEngine engine, float snapshotPeriod) { TimeSpan period = TimeSpan.FromHours(snapshotPeriod); ICleanUpPolicy policy = (ICleanUpPolicy) Kernel[PrevalenceFacility.CleanupPolicyComponentPropertyKey]; SnapshotTaker taker = new SnapshotTaker(engine, period, policy); Kernel.AddComponentInstance(PrevalenceFacility.SnapShotTakerComponentPropertyKey, taker); }
protected void Application_Start(Object sender, EventArgs e) { string datapath = ConfigurationSettings.AppSettings["DataPath"]; long counter = Convert.ToInt64(ConfigurationSettings.AppSettings["DataSnapshot"]); long delay = 0; engine = PrevalenceActivator.CreateEngine(typeof(PetStore), datapath); timer = new Timer(new TimerCallback(TakeSnapshot), null, delay, counter); }
public void Init() { DefaultConfigurationStore store = new DefaultConfigurationStore(); XmlInterpreter interpreter = new XmlInterpreter( new ConfigResource() ); interpreter.ProcessResource(interpreter.Source, store); _container = new PestControlContainer(interpreter); _model = (PestControlModel) _container["pestcontrolModel"]; _engine = (PrevalenceEngine) _container["prevalenceengine"]; }
static PrevalenceEngine GetCurrent(string methodName) { PrevalenceEngine current = PrevalenceEngine.Current; if (null == current) { throw new InvalidOperationException(string.Format("{0} can only be called during the execution of a command or query!")); } return(current); }
/// <summary> /// Returns a list with all the files that are no /// longer necessary to restore the state of /// the prevalence system. /// </summary> /// <param name="engine">the prevalence engine</param> /// <returns>list with files sorted by name</returns> public static FileInfo[] GetUnnecessaryPrevalenceFiles(PrevalenceEngine engine) { FileInfo[] all = GetPrevalenceFilesSortedByName(engine); int lastSnapshotIndex = FindLastSnapshot(all); if (lastSnapshotIndex > 0) { return GetFileInfoRange(all, 0, lastSnapshotIndex); } else { return NullCleanUpPolicy.EmptyFileInfoArray; } }
/// <summary> /// Creates a new SnapshotTaker for the PrevalenceEngine engine /// with a period between snapshots equals to period. Files /// will be removed according to the specified cleanUpPolicy object. /// </summary> /// <param name="engine">prevalence engine to take snapshots from</param> /// <param name="period">period between snapshots</param> /// <param name="cleanUpPolicy">clean up policy</param> public SnapshotTaker(PrevalenceEngine engine, TimeSpan period, ICleanUpPolicy cleanUpPolicy) { if (null == engine) { throw new ArgumentNullException("engine"); } if (null == cleanUpPolicy) { throw new ArgumentNullException("cleanUpPolicy"); } _cleanUpPolicy = cleanUpPolicy; _timer = new Timer(new TimerCallback(OnTimer), engine, period, period); }
/// <summary> /// Creates a new prevalence engine for the prevalent system /// type specified by the systemType argument with the option /// to automatically support the migration from older serialization /// layout versions. /// </summary> /// <param name="systemType">prevalent system type, must be serializable</param> /// <param name="prevalenceBase">directory where to store log files</param> /// <param name="autoVersionMigration">include support for auto version migration</param> /// <param name="handler">delegate to receive notifications about any exceptions during recovery</param> /// <returns>a new prevalence engine</returns> public static PrevalenceEngine CreateEngine(System.Type systemType, string prevalenceBase, bool autoVersionMigration, PrevalenceEngine.ExceptionDuringRecoveryHandler handler) { CheckEngineParameters(systemType, prevalenceBase); BinaryFormatter formatter; if (autoVersionMigration) { formatter = CreateAutoVersionMigrationFormatter(systemType); } else { formatter = CreateBinaryFormatter(); } return CreateRequestedEngine(systemType, prevalenceBase, formatter, handler); }
public MainForm() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // _engine = PrevalenceActivator.CreateEngine(typeof(TaskManagementSystem), PrevalenceBase); _system = _engine.PrevalentSystem as TaskManagementSystem; RefreshProjectView(); _status.Text = PrevalenceBase; }
public PrevalentSystemProxy(PrevalenceEngine engine, MarshalByRefObject system) : base(system.GetType()) { _engine = engine; _system = system; }
private static void InternalCreateCacheSystem(string dataDir) { if (!Directory.Exists(dataDir)) { LoggingService.InfoFormatted("建立缓存目录{0}", new object[] { dataDir }); Directory.CreateDirectory(dataDir); } _engine = PrevalenceActivator.CreateTransparentEngine(typeof(CacheSystem), dataDir); _system = _engine.PrevalentSystem as CacheSystem; }
public TestCurrentCommandAndQuery(PrevalenceEngine engine) { _engine = engine; }
public TransparentPrevalenceEngine(System.Type systemType, string prevalenceBase, BinaryFormatter formatter, PrevalenceEngine.ExceptionDuringRecoveryHandler handler) : base(systemType, prevalenceBase, formatter, handler) { CreateProxy(); }
static MoteurPrevalence() { Moteur = PrevalenceActivator.CreateEngine(typeof(Stockage), Path.Combine(Path.GetTempPath(), "Persistance")); }
/// <summary> /// Should be implemented by derived classes. /// See <see cref="ICleanUpPolicy.SelectFiles"/> for details. /// </summary> /// <param name="engine"></param> /// <returns></returns> public abstract FileInfo[] SelectFiles(PrevalenceEngine engine);
/// <summary> /// Same as <see cref="PrevalenceBaseUtil.GetUnnecessaryPrevalenceFiles"/>. /// </summary> /// <param name="engine"></param> /// <returns></returns> public override FileInfo[] SelectFiles(PrevalenceEngine engine) { return GetUnnecessaryPrevalenceFiles(engine); }
/// <summary> /// Returns the last (most recent) snapshot file in the <see cref="PrevalenceEngine.PrevalenceBase"/> /// folder or null when no snapshot exists. /// </summary> /// <param name="engine">the prevalence engine</param> /// <returns></returns> public static FileInfo FindLastSnapshot(PrevalenceEngine engine) { FileInfo[] snapshots = GetSnapshotFiles(engine); if (snapshots.Length > 0) { return snapshots[snapshots.Length-1]; } return null; }
/// <summary> /// Returns all snapshot files in the <see cref="PrevalenceEngine.PrevalenceBase"/> /// folder sorted by filename. /// </summary> /// <param name="engine">the prevalence engine</param> /// <returns></returns> public static FileInfo[] GetSnapshotFiles(PrevalenceEngine engine) { FileInfo[] files = engine.PrevalenceBase.GetFiles("*.snapshot"); SortFilesByName(files); return files; }
private static PrevalenceEngine CreateRequestedEngine(System.Type systemType, string prevalenceBase, BinaryFormatter formatter, PrevalenceEngine.ExceptionDuringRecoveryHandler handler) { if (Attribute.IsDefined(systemType, typeof(Bamboo.Prevalence.Attributes.TransparentPrevalenceAttribute), false)) { return new TransparentPrevalenceEngine(systemType, prevalenceBase, formatter, handler); } else { return new PrevalenceEngine(systemType, prevalenceBase, formatter, handler); } }
public RegistrationController( PrevalenceEngine engine ) { _engine = engine; }
protected void Application_Start(object sender, EventArgs args) { _engine = PrevalenceActivator.CreateTransparentEngine(typeof(UserLoginSystem), PrevalenceBase); }
/// <summary> /// Creates a new SnapshotTaker for the PrevalenceEngine engine /// with a period between snapshots equals to period but with no file /// cleanup policy (no files will be deleted from the prevalence base folder). /// </summary> /// <param name="engine">prevalence engine to take snapshots from</param> /// <param name="period">period between snapshots</param> public SnapshotTaker(PrevalenceEngine engine, TimeSpan period) : this(engine, period, NullCleanUpPolicy.Default) { }
/// <summary> /// Creates a new prevalence engine for the prevalent system /// type specified by the systemType argument. /// </summary> /// <param name="systemType">prevalent system type, must be serializable</param> /// <param name="prevalenceBase">directory where to store log files</param> /// <param name="formatter">serialization formatter that should be used for reading from/writing to the logs</param> /// <param name="handler">delegate to receive notifications of any exceptions thrown during recovery</param> /// <returns>a new prevalence engine</returns> public static PrevalenceEngine CreateEngine(System.Type systemType, string prevalenceBase, BinaryFormatter formatter, PrevalenceEngine.ExceptionDuringRecoveryHandler handler) { CheckEngineParameters(systemType, prevalenceBase); Assertion.AssertParameterNotNull("formatter", formatter); return CreateRequestedEngine(systemType, prevalenceBase, formatter, handler); }
private void SetupEngine() { engine = PrevalenceActivator.CreateTransparentEngine(typeof (CacheSystem), dataDir); system = engine.PrevalentSystem as CacheSystem; taker = new SnapshotTaker(engine, TimeSpan.FromMinutes(5), CleanUpAllFilesPolicy.Default); }