示例#1
0
        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);
        }
示例#2
0
        /// <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);
        }