コード例 #1
0
        /// <summary>
        /// Generates a new Nettle compiler with custom functions
        /// </summary>
        /// <returns>The Nettle compiler</returns>
        public INettleCompiler Generate()
        {
            var dataResolver = new NettleDataResolver();
            var webResolver  = new NettleWebResolver();

            var appSettings       = ConfigurationManager.AppSettings;
            var defaultTimeZoneId = appSettings["DefaultTimeZoneId"];

            NettleEngine.RegisterResolvers
            (
                dataResolver,
                webResolver
            );

            if (false == String.IsNullOrEmpty(defaultTimeZoneId))
            {
                NettleEngine.SetDefaultTimeZone
                (
                    defaultTimeZoneId
                );
            }

            return(NettleEngine.GetCompiler
                   (
                       _customFunctions
                   ));
        }
コード例 #2
0
        public DemoForm()
        {
            InitializeComponent();

            var dataResolver = new NettleDataResolver();

            var connectionString = ConfigurationManager.AppSettings
                                   [
                "DatabaseConnectionString"
                                   ];

            if (false == String.IsNullOrEmpty(connectionString))
            {
                dataResolver.ConnectionRepository.AddConnection
                (
                    new SqlClientConnection
                    (
                        "Demo",
                        connectionString
                    )
                );
            }

            NettleEngine.RegisterResolvers
            (
                new DefaultNettleResolver(),
                new NettleWebResolver(),
                new NettleNCalcResolver(),
                dataResolver
            );

            _compiler = NettleEngine.GetCompiler();

            _compiler.AutoRegisterViews
            (
                "../../Templates"
            );
        }