/// <summary>Grab and cache options; verify options are valid</summary>
        private void HandleExprOptions(StringTemplate self)
        {
            // make sure options don't use format / renderer.  They are usually
            // strings which might invoke a string renderer etc...
            formatString = null;
            StringTemplateAST wrapAST = (StringTemplateAST)GetOption("wrap");
            if (wrapAST != null)
            {
                wrapString = EvaluateExpression(self, wrapAST);
            }
            StringTemplateAST nullValueAST = (StringTemplateAST)GetOption("null");
            if (nullValueAST != null)
            {
                nullValue = EvaluateExpression(self, nullValueAST);
            }
            StringTemplateAST separatorAST = (StringTemplateAST)GetOption("separator");
            if (separatorAST != null)
            {
                separatorString = EvaluateExpression(self, separatorAST);
            }

            // following addition inspired by John Snyders
            StringTemplateAST formatAST = (StringTemplateAST)GetOption("format");
            if (formatAST != null)
            {
                formatString = EvaluateExpression(self, formatAST);
            }

            // Check that option is valid
            if (options != null)
            {
                IEnumerator iter = options.Keys.GetEnumerator();
                while (iter.MoveNext())
                {
                    string option = (string)iter.Current;
                    if (!supportedOptions.Contains(option))
                    {
                        self.Warning("ignoring unsupported option: " + option);
                    }
                }
            }
        }
Exemple #2
0
        /** <summary>Grab and cache options; verify options are valid</summary> */
        protected virtual void HandleExprOptions( StringTemplate self )
        {
            // make sure options don't use format / renderer.  They are usually
            // strings which might invoke a string renderer etc...
            _formatString = null;
            StringTemplateAST wrapAST = (StringTemplateAST)GetOption( "wrap" );
            if ( wrapAST != null )
            {
                _wrapString = EvaluateExpression( self, wrapAST );
            }
            StringTemplateAST nullValueAST = (StringTemplateAST)GetOption( "null" );
            if ( nullValueAST != null )
            {
                _nullValue = EvaluateExpression( self, nullValueAST );
            }
            StringTemplateAST separatorAST = (StringTemplateAST)GetOption( "separator" );
            if ( separatorAST != null )
            {
                _separatorString = EvaluateExpression( self, separatorAST );
            }
            // following addition inspired by John Snyders
            StringTemplateAST formatAST =
                (StringTemplateAST)GetOption( "format" );
            if ( formatAST != null )
            {
                _formatString = EvaluateExpression( self, formatAST );
            }

            // Check that option is valid
            if ( _options != null )
            {
                foreach ( string option in _options.Keys )
                {
                    if ( !_supportedOptions.Contains( option ) )
                        self.Warning( "ignoring unsupported option: " + option );
                }
            }
        }