/// <summary> /// Light over approximation test for possibility of instance removing in given view /// </summary> /// <param name="instance">Instance that is tested for removing possibility</param> /// <param name="view">View where removing will be processed</param> /// <returns><c>true</c> if instance can be removed, <c>false</c> otherwise</returns> internal bool CanRemove(Instance instance, ExecutionView view) { var currentBlock = instance.CreationBlock; if (currentBlock == null) { return(false); } var hasRemoveProvider = false; while (currentBlock != null) { var removeProviders = currentBlock.RemoveProviders(instance); foreach (var removeProvider in removeProviders) { if (removeProvider == null) { //removing is not possible return(false); } hasRemoveProvider = true; } currentBlock = view.NextBlock(currentBlock); } return(hasRemoveProvider); }
internal bool Remove(Instance instance, ExecutionView view) { var currentBlock = instance.CreationBlock; if (currentBlock == null) { return(false); } while (currentBlock != null) { var removeProviders = currentBlock.RemoveProviders(instance); foreach (var removeProvider in removeProviders) { if (removeProvider == null) { //removing is not possible view.Abort("Cannot remove because of missing RemoveProvider"); return(false); } var transform = removeProvider.Remove(); view.Apply(transform); if (view.IsAborted) { return(false); } } currentBlock = view.NextBlock(currentBlock); } return(true); }
/// <summary> /// Get variable for given instance in block associated with current /// edits provider call. Minimal sub transformation for getting common scope /// is used. /// </summary> /// <param name="instance">Instance which variable is searched.</param> /// <param name="view">The view.</param> /// <returns>VariableName.</returns> public VariableName GetVariableFor(Instance instance, ExecutionView view) { var transformation = new ScopeBlockTransformation(_block, instance); view.Apply(transformation); return(transformation.ScopeVariable); }
/// <summary> /// Applies transformation at the given view. /// </summary> /// <param name="view">The view to be transformed.</param> internal void Apply(ExecutionView view) { View = view; try { apply(); } finally { View = null; } }
/// <summary> /// Clone current view into view that is independent on current view. /// <remarks>Only one view in views cloning hierarchy can be committed</remarks>. /// </summary> /// <returns>Cloned view.</returns> /// <exception cref="System.NotSupportedException"> /// Cannot clone aborted view /// or /// Cannot clone committed view /// </exception> public ExecutionView Clone() { if (IsAborted) { throw new NotSupportedException("Cannot clone aborted view"); } if (IsCommitted) { throw new NotSupportedException("Cannot clone committed view"); } var clone = new ExecutionView(_result); clone._appliedTransformations.AddRange(_appliedTransformations); clone._viewData.FillFrom(_viewData); return(clone); }