Ejemplo n.º 1
0
        /// <summary>
        /// Performs a script file include
        /// </summary>
        protected virtual void IncludeScriptFile(IConfigSectionNode node, Outputs outputs)
        {
            var fn = node.Value;

            if (fn != null)
            {
                if (!File.Exists(fn))
                {
                    foreach (var path in Schema.IncludePaths)
                    {
                        fn = Path.Combine(path, node.Value);
                        if (File.Exists(fn))
                        {
                            break;
                        }
                    }
                }
            }
            if (fn == null || !File.Exists(fn))
            {
                throw new SchemaCompilationException(node.RootPath,
                                                     StringConsts.RELATIONAL_COMPILER_INCLUDE_SCRIPT_NOT_FOUND_ERROR
                                                     .Args(node.ValueAsString(StringConsts.NULL_STRING), node.RootPath));
            }

            var content = File.ReadAllText(fn);

            var outputName = node.AttrByName(SCRIPT_OUTPUT_NAME_ATTR).Value;

            var output = outputName.IsNullOrWhiteSpace() ? outputs.CurrentOrUnspecified : outputs[outputName];

            output.Append(content);
        }