private void ResolveTemplates(IList <IVariable> variables, String defaultRoot, CancellationToken cancellationToken, ref Int32 fileCount)
        {
            for (int i = 0; i < (variables?.Count ?? 0);)
            {
                if (variables[i] is VariablesTemplateReference)
                {
                    // Load the template.
                    var    reference        = variables[i] as VariablesTemplateReference;
                    String templateFilePath = m_fileProvider.ResolvePath(defaultRoot: defaultRoot, path: reference.Name);
                    PipelineFile <VariablesTemplate> templateFile = LoadFile <VariablesTemplate, VariablesTemplateConverter>(templateFilePath, reference.Parameters, cancellationToken, ref fileCount);
                    VariablesTemplate template = templateFile.Object;

                    // Merge the template.
                    variables.RemoveAt(i);
                    if (template.Variables != null)
                    {
                        foreach (IVariable variable in template.Variables)
                        {
                            variables.Insert(i, variable);
                        }

                        i += template.Variables.Count;
                    }
                }
                else
                {
                    i++;
                }
            }
        }
Esempio n. 2
0
        public Object ReadYaml(IParser parser, Type type)
        {
            var result = new VariablesTemplate();

            parser.Expect <MappingStart>();
            while (parser.Allow <MappingEnd>() == null)
            {
                Scalar scalar = parser.Expect <Scalar>();
                switch (scalar.Value ?? String.Empty)
                {
                case YamlConstants.Variables:
                    result.Variables = ConverterUtil.ReadVariables(parser, simpleOnly: true);
                    break;

                default:
                    throw new SyntaxErrorException(scalar.Start, scalar.End, $"Unexpected variables template property: '{scalar.Value}'");
                }
            }

            return(result);
        }