コード例 #1
0
ファイル: ActionStepHandler.cs プロジェクト: Burakovivan/VSG
        public ActionStepHandler(ElementSelector elementSelector, int actionType)
        {
            TextBoxDict = new Dictionary <string, TextBox>();
            var actionTypeValue = (EventAction)actionType;

            switch (actionTypeValue)
            {
            case EventAction.Add:
                ElementStep = new AddStep(elementSelector);
                break;

            case EventAction.Remove:
                ElementStep = new RemoveStep(elementSelector);
                break;

            case EventAction.Move:
                if (elementSelector.ElementType == ElementType.Event)
                {
                    ElementStep = new MoveStep(elementSelector);
                }
                break;

            case EventAction.SetEffect:
                ElementStep = new SetEffectStep(elementSelector);
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// Applies a <see cref="RemoveStep"/> to a <see cref="TemporaryDirectory"/>.
        /// </summary>
        /// <param name="step">The <see cref="Archive"/> to apply.</param>
        /// <param name="workingDir">The <see cref="TemporaryDirectory"/> to apply the changes to.</param>
        /// <exception cref="IOException">A path specified in <paramref name="step"/> is illegal.</exception>
        public static void Apply([NotNull] this RemoveStep step, [NotNull] TemporaryDirectory workingDir)
        {
            #region Sanity checks
            if (step == null)
            {
                throw new ArgumentNullException(nameof(step));
            }
            if (workingDir == null)
            {
                throw new ArgumentNullException(nameof(workingDir));
            }
            #endregion

            #region Path validation
            if (string.IsNullOrEmpty(step.Path))
            {
                throw new IOException(string.Format(Resources.RecipeInvalidPath, "(empty)"));
            }
            string path = FileUtils.UnifySlashes(step.Path);
            if (FileUtils.IsBreakoutPath(path))
            {
                throw new IOException(string.Format(Resources.RecipeInvalidPath, path));
            }
            #endregion

            string absolutePath = Path.Combine(workingDir, path);
            if (Directory.Exists(absolutePath))
            {
                Directory.Delete(absolutePath, recursive: true);
            }
            else
            {
                File.Delete(absolutePath);
            }

            // Update in flag files as well
            FlagUtils.Remove(Path.Combine(workingDir, FlagUtils.XbitFile), path);
            FlagUtils.Remove(Path.Combine(workingDir, FlagUtils.SymlinkFile), path);
        }
コード例 #3
0
 /// <summary>
 /// Removes a file or directory from the implementation.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="metadata">The path of the file or directory.</param>
 /// <exception cref="UnauthorizedAccessException">Access to a resource was denied.</exception>
 /// <exception cref="IOException">An IO operation failed.</exception>
 public static void Remove(this IBuilder builder, RemoveStep metadata)
 => builder.Remove(metadata.Path);