Exemplo n.º 1
0
        private void AddNamespaces()
        {
            // Add all Wyam.Common namespaces
            _engine.Namespaces.AddRange(typeof(IModule).Assembly.GetTypes()
                                        .Where(x => !string.IsNullOrWhiteSpace(x.Namespace))
                                        .Select(x => x.Namespace)
                                        .Distinct());

            // Add all module namespaces
            _engine.Namespaces.AddRange(ClassCatalog.GetClasses <IModule>().Select(x => x.Namespace));
        }
        private void AddShortcodes()
        {
            foreach (Type shortcode in ClassCatalog.GetClasses <IShortcode>())
            {
                _engine.Shortcodes.Add(shortcode);

                // Special case for the meta shortcode to register with the name "="
                if (shortcode.Equals(typeof(Core.Shortcodes.Metadata.Meta)))
                {
                    _engine.Shortcodes.Add("=", shortcode);
                }
            }
        }
Exemplo n.º 3
0
        private void AddNamespaces()
        {
            // Add all Wyam.Common namespaces
            // the JetBrains.Profiler filter is needed due to DotTrace dynamically
            // adding a reference to that assembly when running under its profiler. We want
            // to exclude it.
            _engine.Namespaces.AddRange(typeof(IModule).Assembly.GetTypes()
                                        .Where(x => !string.IsNullOrWhiteSpace(x.Namespace) && !x.Namespace.StartsWith("JetBrains.Profiler"))
                                        .Select(x => x.Namespace)
                                        .Distinct());

            // Add all module namespaces
            _engine.Namespaces.AddRange(ClassCatalog.GetClasses <IModule>().Select(x => x.Namespace));
        }
Exemplo n.º 4
0
        private void Evaluate(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return;
            }

            Stopwatch stopwatch = Stopwatch.StartNew();

            using (Trace.WithIndent().Information("Evaluating configuration script"))
            {
                CacheManager cacheManager = new CacheManager(_engine, _scriptManager, ConfigDllPath, ConfigHashPath, OutputScriptPath);
                cacheManager.EvaluateCode(code, ClassCatalog.GetClasses <IModule>().ToList(), OutputScript, IgnoreConfigHash, NoOutputConfigAssembly);

                stopwatch.Stop();
                Trace.Information($"Evaluated configuration script in {stopwatch.ElapsedMilliseconds} ms");
            }
        }
Exemplo n.º 5
0
        private void Evaluate(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return;
            }

            System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew();
            using (Trace.WithIndent().Information("Evaluating configuration script"))
            {
                _scriptManager.Create(code, ClassCatalog.GetClasses <IModule>().ToList(), _engine.Namespaces);
                WriteScript(_scriptManager.Code);
                _scriptManager.Compile(AppDomain.CurrentDomain.GetAssemblies());
                _engine.DynamicAssemblies.Add(_scriptManager.RawAssembly);
                _scriptManager.Evaluate(_engine);
                stopwatch.Stop();
                Trace.Information($"Evaluated configuration script in {stopwatch.ElapsedMilliseconds} ms");
            }
        }