Beispiel #1
0
 public void TestDefineConst()
 {
     using (XmlReader input = GetInput("TestDefineConst.xml"))
     {
         using (XmlWriter output = GetOutput())
         {
             ConfigPreprocessor      preprocessor = new ConfigPreprocessor();
             PreprocessorEnvironment env          =
                 preprocessor.PreProcess(input, output, _resolver, null);
             Assert.AreEqual(env.EvalSymbol("var1").GetTextValue(), "value1");
         }
     }
 }
        /// <summary>
        /// Pres the process.	
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="output">The output.</param>
        /// <param name="resolver">The resolver.</param>
        /// <param name="inputUri">The input_uri.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public PreprocessorEnvironment PreProcess(XmlReader input, XmlWriter output,
                                                  XmlUrlResolver resolver, Uri inputUri)
        {
            // The base URI is needed to resolve includes of relative paths, as well as to generate
            // error messages.
            // If none is given explicitly, try to use the XmlReader's BaseUri.  
            // If that doesn't exist either, use the current working directory and a fake filename.
            Uri base_uri = inputUri ??
                           ( String.IsNullOrEmpty( input.BaseURI )
                                 ? new Uri(
                                       Path.Combine(
                                           Environment.CurrentDirectory,
                                           "nofile.xml" ) )
                                 : new Uri( input.BaseURI ) );
            // Create the environment
            _env = new PreprocessorEnvironment( _settings, base_uri, resolver );
            // Load the input document
            XDocument doc = XDocument.Load( input, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo );
            // Process the input document's nodes and write the results to the output stream
            foreach ( XNode out_node in
                doc.Nodes().SelectMany(
                    node => _env._DefaultNodeProcessor.Process( node ) ).Where( node => !(node is XText)) )
            {
                out_node.WriteTo( output );
            }

            // Notify listeners of all files encountered.
            if (SubfileLoaded != null)
            {
                foreach (Uri path in _env.Fileset)
                {
                    SubfileLoaded( path );
                }
            }
            return _env;
        }
Beispiel #3
0
 public IfDefProcessor(PreprocessorEnvironment env)
     : this(env._Settings.Namespace.GetName("ifdef"), env)
 {
 }
 protected ConditionalProcessor(XName targetElementName, PreprocessorEnvironment env)
     : base( targetElementName, env )
 {
 }
 public ScopeProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("scope"), env)
 {
 }
 public ConfigTemplateProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("config-template"), env)
 {
 }
 public ForProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("for"), env)
 {
 }
 public ImportProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("import"), env)
 {
 }
Beispiel #9
0
 public TestElementProcessor(PreprocessorEnvironment env)
     : base(XmlNs.PreProcessor.GetName("test"), env)
 {
 }
 public ExpandSymbolProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("_Unused_Name_"), env)
 {
 }
Beispiel #11
0
 public CountProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("count"), env)
 {
 }
 public TestElementProcessor(PreprocessorEnvironment env)
     : base( XmlNs.PreProcessor.GetName( "test" ), env )
 {
 }
 public IgnoreProcessor(XName elementNameToIgnore, PreprocessorEnvironment env)
     : base(elementNameToIgnore, env)
 {
 }
 public EvalProcessor(PreprocessorEnvironment env)
     : base( env._Settings.Namespace.GetName("eval"), env)
 {
 }
 public ScopeProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("scope"), env)
 {
 }
 public CountProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("count"), env)
 {
 }
 public IgnoreProcessor(XName elementNameToIgnore, PreprocessorEnvironment env)
     : base( elementNameToIgnore, env )
 {
 }
 public DefaultProcessor(PreprocessorEnvironment env) : base( env._Settings.Namespace.GetName("define"), env )
 {
     _processors = new Dictionary< XName, IElementProcessor >();
     _expand_symbol_processor = new ExpandSymbolProcessor( env );
     _LoadElementProcessors();
 }
 public ProcessingInstructionProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("processing-instruction"), env)
 {
 }
 public CreateElementProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("element"), env)
 {
 }
Beispiel #21
0
 public IfNDefProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("ifndef"), env)
 {
 }
Beispiel #22
0
 public ProcessingInstructionProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("processing-instruction"), env)
 {
 }
 public DefaultProcessor(PreprocessorEnvironment env) : base(env._Settings.Namespace.GetName("define"), env)
 {
     _processors = new Dictionary <XName, IElementProcessor>();
     _expand_symbol_processor = new ExpandSymbolProcessor(env);
     _LoadElementProcessors();
 }
Beispiel #24
0
 protected ConditionalProcessor(XName targetElementName, PreprocessorEnvironment env)
     : base(targetElementName, env)
 {
 }
 public DefineProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("define"), env)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElementProcessor" /> class.
 /// </summary>
 /// <param name="targetElementName">The target_element_name.</param>
 /// <param name="env">The env.</param>
 /// <remarks></remarks>
 protected ElementProcessor(XName targetElementName, PreprocessorEnvironment env)
 {
     TargetElementName = targetElementName;
     _Env = env;
 }
Beispiel #27
0
 public EvalProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("eval"), env)
 {
 }
 protected IfDefProcessor(XName elementName, PreprocessorEnvironment env)
     : base( elementName, env )
 {
 }
Beispiel #29
0
 protected IfDefProcessor(XName elementName, PreprocessorEnvironment env)
     : base(elementName, env)
 {
 }
 public IfDefProcessor(PreprocessorEnvironment env)
     : this(env._Settings.Namespace.GetName("ifdef"), env)
 {
 }
 public ExpandSymbolProcessor(PreprocessorEnvironment env)
     : base( env._Settings.Namespace.GetName("_Unused_Name_"), env)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ElementProcessor" /> class.	
 /// </summary>
 /// <param name="targetElementName">The target_element_name.</param>
 /// <param name="env">The env.</param>
 /// <remarks></remarks>
 protected ElementProcessor(XName targetElementName, PreprocessorEnvironment env)
 {
     TargetElementName = targetElementName;
     _Env = env;
 }
 public DefineProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("define"), env)
 {
 }
Beispiel #34
0
 public IncludeProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("include"), env)
 {
 }
 public CreateElementProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("element"), env)
 {
 }
 public ConfigTemplateProcessor(PreprocessorEnvironment env)
     : base( env._Settings.Namespace.GetName("config-template"), env )
 {
 }
 public IfProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("if"), env)
 {
 }
 public ForEachProcessor(PreprocessorEnvironment env)
     : base(env._Settings.Namespace.GetName("for-each"), env)
 {
 }