protected CumulationAwareContext(VaultCompiler compiler) : base(compiler) { lock (compiler._barrier) { Changeset = compiler._changeSet.ToArray(); CompilingBaseline = compiler._compilingBaseline; if (CompilingBaseline) { // until we've compiled baseline, we're always instantly embracing all the changes compiler._changeSet.Clear(); Changeset = new ElementChangedEventArgs[0]; // however, when the baseline is ready and we switch to cumulative mode, then // changes should be deleted only when the worker has successfully incorporated them } } }
private void SignificantChangeProcessor(ElementChangedEventArgs e) { lock (_barrier) { _changeSet.Add(e); GetCompiledAsync(); } }
private bool SignificantChangeFilter(ElementChangedEventArgs e) { // we CARE about: // 1. deleted svd/fla (maybe indirectly via recursion) // 2. deleted node (maybe indirectly via recursion) // 3. added svd/fla // 4. added node // 5. changed fla, i.e. "elfCode" value of a "...\_formulaDeclarations\*\" branch got its content changed // we DON'T CARE about: // anything else // special cases of NOT CARING: // 1. renamed anything // let's ignore renaming so far, since it's unusual for this app to rename values that have system names // 2. changed svd's external link, i.e. "repositoryValue" value of a "...\_sourceValueDeclarations\*\" branch got its content changed // we don't care about the latter since repoValue never gets burned into assembly, but rather gets cached // whereas cached values get cleared anyways on the compiledscenario instance being reused // any branch event is important, since both nodes and svds/flae are branches if (e.Subject is IBranch) { // a special case we process here // imagine that a "_sourceValueDeclarations" node is being added to just create scenario node // this event in itself is totally irrelevant to recompilation, since it brings nothing new to the table // however, when that node gains any children - then we surely proceed to recompile the assembly var b = (IBranch)e.Subject; if (e.Reason == EventReason.Add && (b.IsFormulaHost() || b.IsSvdHost())) { return false; } if (e.Reason == EventReason.Add || e.Reason == EventReason.Remove) { return true; } else { return false; } } else { var value = (IValue)e.Subject; if (value.Name == "elfCode") { if (e.Reason == EventReason.Content) { var oldContent = ((Stream)e.OldValue).AsString(); var newContent = ((Stream)e.NewValue).AsString(); return oldContent != newContent; } else if (e.Reason == EventReason.Remove) { return true; } else { return false; } } else { return false; } } }