Exemplo n.º 1
0
        private static bool CreateInstance(out IYiScript script)
        {
            var appdomain = AppDomainFactory.CreateAppDomain(FolderName);

            script = AppDomainFactory.InstantiatePlugin(Environment.CurrentDirectory + "\\" + CachedPath, appdomain);
            return(script != null);
        }
Exemplo n.º 2
0
        private static void WatcherOnChanged(object sender, FileSystemEventArgs e)
        {
            Watcher.EnableRaisingEvents = false;
            var realFolder = e.FullPath.Replace(Environment.CurrentDirectory, "").Replace(@"\Scripts\ScriptingProjects\", "").Split('\\')[0];

            Output.WriteLine($"{e.ChangeType} -> {e.Name} -> Recompiling: {realFolder}");

            if (AppDomainFactory.AppDomains.TryGetValue(realFolder, out var old))
            {
                AppDomainFactory.UnloadPlugin(old);
            }

            var container = ScriptEngine.Scripts.FirstOrDefault(c => string.Equals(c.Value.FolderName, realFolder, StringComparison.InvariantCultureIgnoreCase)).Value;

            if (container == null)
            {
                Watcher.EnableRaisingEvents = true;
                return;
            }

            if (container.Compile())
            {
                ScriptEngine.Scripts.AddOrUpdate(container.ScriptType, container);
            }


            Output.WriteLine($"{realFolder} Recompiled!");
            Watcher.EnableRaisingEvents = true;
        }