예제 #1
0
        public HostedScriptEngine()
        {
            _engine = new ScriptingEngine();
            _env    = new RuntimeEnvironment();
            _engine.AttachAssembly(System.Reflection.Assembly.GetExecutingAssembly(), _env);

            _globalCtx = new SystemGlobalContext();
            _globalCtx.EngineInstance = _engine;

            _env.InjectObject(_globalCtx, false);
        }
예제 #2
0
        private static void RegisterGlobalContext(Type contextType, RuntimeEnvironment environment)
        {
            var attribData = (GlobalContextAttribute)contextType.GetCustomAttributes(typeof(GlobalContextAttribute), false)[0];
            if (attribData.ManualRegistration)
                return;

            var method = contextType.GetMethod(INSTANCE_RETRIEVER_NAME, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
            System.Diagnostics.Trace.Assert(method != null, "Global context must have a static method " + INSTANCE_RETRIEVER_NAME);
            var instance = (IAttachableContext)method.Invoke(null, null);
            GlobalsManager.RegisterInstance(instance);
            environment.InjectObject(instance, false);

        }
예제 #3
0
        public WebApplicationEngine()
        {
            Engine             = new ScriptingEngine();
            Environment        = new RuntimeEnvironment();
            Engine.Environment = Environment;

            Engine.AttachAssembly(System.Reflection.Assembly.GetExecutingAssembly(), Environment);
            Engine.AttachAssembly(typeof(SystemGlobalContext).Assembly, Environment);
            Environment.InjectObject(new WebGlobalContext());
            Engine.Initialize();
            // TODO Убрать после реализации https://github.com/EvilBeaver/OneScript/issues/641
            TypeManager.RegisterType("Сценарий", typeof(UserScriptContextInstance));
            Engine.UpdateContexts();
        }
예제 #4
0
        public HostedScriptEngine()
        {
            _engine = new ScriptingEngine();
            _env = new RuntimeEnvironment();
            _engine.AttachAssembly(System.Reflection.Assembly.GetExecutingAssembly(), _env);

            _globalCtx = new SystemGlobalContext();
            _globalCtx.EngineInstance = _engine;

            _env.InjectObject(_globalCtx, false);
            _engine.Environment = _env;
            
            InitLibrariesByDefault();

        }
예제 #5
0
        private static void RegisterGlobalContext(Type contextType, RuntimeEnvironment environment)
        {
            var attribData = (GlobalContextAttribute)contextType.GetCustomAttributes(typeof(GlobalContextAttribute), false)[0];

            if (attribData.ManualRegistration)
            {
                return;
            }

            var method = contextType.GetMethod(INSTANCE_RETRIEVER_NAME, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            System.Diagnostics.Trace.Assert(method != null, "Global context must have a static method " + INSTANCE_RETRIEVER_NAME);
            var instance = (IAttachableContext)method.Invoke(null, null);

            GlobalsManager.RegisterInstance(instance);
            environment.InjectObject(instance, false);
        }
예제 #6
0
        public HostedScriptEngine()
        {
            _engine = new ScriptingEngine();
            _env    = new RuntimeEnvironment();
            _engine.AttachAssembly(System.Reflection.Assembly.GetExecutingAssembly(), _env);

            _globalCtx = new SystemGlobalContext();
            _globalCtx.EngineInstance = _engine;

            _env.InjectObject(_globalCtx, false);

            InitializationCallback = (eng, env) =>
            {
                var templateFactory = new DefaultTemplatesFactory();
                var storage         = new TemplateStorage(templateFactory);
                env.InjectObject(storage);
                GlobalsManager.RegisterInstance(storage);
            };

            _engine.Environment = _env;
        }
예제 #7
0
 public void InjectObject(IAttachableContext obj, bool asDynamicScope)
 {
     _env.InjectObject(obj, asDynamicScope);
 }