Пример #1
0
        public static ConsoleContext Constructor()
        {
            var provider = GlobalsManager.GetGlobalContext <ConsoleProvider>();

            SystemLogger.Write("WARNING: Constructor of Console is obsolete. Use global property Консоль/Console");

            return(provider.Console);
        }
Пример #2
0
        private void CreateDump(Stream output)
        {
            var offset = (int)output.Length;

            var engine = new HostedScriptEngine
            {
                CustomConfig = ScriptFileHelper.CustomConfigPath(_codePath)
            };

            engine.Initialize();
            ScriptFileHelper.OnBeforeScriptRead(engine);
            var source   = engine.Loader.FromFile(_codePath);
            var compiler = engine.GetCompilerService();

            engine.SetGlobalEnvironment(new DoNothingHost(), source);
            var entry = compiler.Compile(source);

            var embeddedContext = engine.GetUserAddedScripts();
            var templates       = GlobalsManager.GetGlobalContext <TemplateStorage>();

            var dump = new ApplicationDump();

            dump.Scripts = new UserAddedScript[]
            {
                new UserAddedScript()
                {
                    Image  = entry,
                    Symbol = "$entry",
                    Type   = UserAddedScriptType.Module
                }
            }.Concat(embeddedContext)
            .ToArray();
            dump.Resources = templates.GetTemplates()
                             .Select(SerializeTemplate)
                             .ToArray();

            using (var bw = new BinaryWriter(output))
            {
                var serializer = new BinaryFormatter();
                serializer.Serialize(output, dump);

                var signature = new byte[]
                {
                    0x4f,
                    0x53,
                    0x4d,
                    0x44
                };
                output.Write(signature, 0, signature.Length);

                bw.Write(offset);

                OutputToFile(output);
            }
        }
Пример #3
0
        public KeyValueConfig GetWorkingConfig()
        {
            var cfgAccessor = GlobalsManager.GetGlobalContext <SystemConfigAccessor>();

            if (!_configInitialized)
            {
                cfgAccessor.Provider = new EngineConfigProvider(CustomConfig);
                cfgAccessor.Refresh();
                _configInitialized = true;
            }
            return(cfgAccessor.GetConfig());
        }
Пример #4
0
        public void AddTemplate(string file, string name, TemplateKind kind = TemplateKind.File)
        {
            var manager = GlobalsManager.GetGlobalContext <TemplateStorage>();

            manager.RegisterTemplate(file, name, kind);
        }