/// <summary> /// Define the given symbol on the current stack frame. /// </summary> /// <param name="constant_def"></param> private void _SetConstant(Constant constant_def) { _env_stack.Peek().Add(constant_def.Name.ToLowerInvariant(), constant_def); }
/// <summary> /// XSLT extension method, called to define a text constant in the /// preprocessor environment. The constant can be referred to symbolically /// in subsequent definitions or expansions. /// </summary> /// <param name="name"></param> /// <param name="value"></param> public void define_text_constant(string name, string value) { _CheckAlreadyDefined(name); Constant const_def = new Constant(); const_def.Name = name; const_def.Value = value; _SetConstant(const_def); }
/// <summary> /// Define the given symbol on the current stack frame. /// </summary> /// <param name="constant_def"></param> private void _SetConstant(Constant constant_def ) { _env_stack.Peek().Add( constant_def.Name.ToLowerInvariant(), constant_def ); }
/// <summary> /// Search for the given symbol definition in the environment. /// </summary> /// <param name="symbol_name"></param> /// <returns></returns> private Constant _InternalGetSymbolDef (string symbol_name) { symbol_name = symbol_name.ToLowerInvariant(); // Try each stack frame. foreach ( ConstantDict frame_defs in _env_stack.ToArray() ) { Constant constant_def; if ( frame_defs.TryGetValue( symbol_name, out constant_def )) return constant_def; } // If nothing is found on the stack, try the system environment variables. string env_var = Environment.GetEnvironmentVariable( symbol_name ); if ( env_var != null ) { Constant c = new Constant(); c.Name = symbol_name; c.Value = env_var; return c; } return null; }
/// <summary> /// XSLT extension method, called to define a notset constant in the preprocessor /// environment. The constant can be referred to symbolically in subsequent /// definitions or expansions. /// </summary> /// <param name="name"></param> /// <param name="value"></param> public void define_nodeset_constant(string name, XPathNodeIterator value) { _CheckAlreadyDefined(name); Constant const_def = new Constant(); const_def.Name = name; const_def.Value = value; _SetConstant(const_def); }