예제 #1
0
        /// <summary>
        ///		Procesa la sentencia que compureba si existe un archivo o directorio
        /// </summary>
        private async Task ProcessExistsAsync(BlockLogModel block, IfExistsSentence sentence, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(sentence.Path))
            {
                AddError(block, "Path is empty");
            }
            else
            {
                string path = Step.Project.GetFullFileName(sentence.Path);

                if (Directory.Exists(path) || File.Exists(path))
                {
                    await ExecuteAsync(block, sentence.IfSentences, cancellationToken);
                }
                else
                {
                    await ExecuteAsync(block, sentence.ElseSentences, cancellationToken);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///		Carga una sentencia IfExists
        /// </summary>
        private BaseSentence LoadIfExistSentence(MLNode rootML)
        {
            IfExistsSentence sentence = new IfExistsSentence();

            // Carga los datos
            AssignSentence(sentence, rootML);
            sentence.Path = rootML.Attributes[TagPath].Value.TrimIgnoreNull();
            // Carga las sentencias
            foreach (MLNode nodeML in rootML.Nodes)
            {
                switch (nodeML.Name)
                {
                case TagThen:
                    sentence.IfSentences.AddRange(LoadSentences(nodeML));
                    break;

                case TagElse:
                    sentence.ElseSentences.AddRange(LoadSentences(nodeML));
                    break;
                }
            }
            // Devuelve la sentencia
            return(sentence);
        }