public bool Equals(ComposeInstructions instructions)
        {
            if (Mode != instructions.Mode)
            {
                return(false);
            }

            if (CustomText != instructions.CustomText)
            {
                return(false);
            }

            if (Files.Count != instructions.Files.Count)
            {
                return(false);
            }

            for (int i = 0; i < Files.Count; i++)
            {
                if (Files[i].Path != instructions.Files[i].Path ||
                    Files[i].CreationDateTime != instructions.Files[i].CreationDateTime)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #2
0
        private void RemoveHiddenFiles(ref ComposeInstructions instructions)
        {
            for (int i = 0; i < instructions.Files.Count; i++)
            {
                string filename = Path.GetFileName(instructions.Files[i].Path);

                if (filename.StartsWith("."))
                {
                    instructions.Files.RemoveAt(i);
                }
            }
        }
Exemple #3
0
        public Dictionary <string, string> Orchestrate(ComposeInstructions instructions)
        {
            var composition = new Dictionary <string, string>();

            var validation = inputValidator.Validate(ref instructions);

            if (!validation.isValid)
            {
                return(composition);
            }

            composer = composerFactory.Build(instructions.Mode);

            composition = composer.Compose(instructions);

            return(composition);
        }
Exemple #4
0
        public (bool isValid, string errorMessage) Validate(ref ComposeInstructions instructions)
        {
            RemoveHiddenFiles(ref instructions);

            string errorMessage = ValidateMode(instructions.Mode);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                return(false, errorMessage);
            }

            errorMessage = ValidateFilesCount(instructions.Files);
            if (!string.IsNullOrEmpty(errorMessage))
            {
                return(false, errorMessage);
            }

            return(true, string.Empty);
        }