public static void AddReferenceAndImportNamespaces(this IScriptExecutor executor, Type[] types)
        {
            Guard.AgainstNullArgument("executor", executor);

            executor.AddReferences(types);
            executor.ImportNamespaces(types);
        }
Ejemplo n.º 2
0
        public static void AddReferences(this IScriptExecutor executor, params Type[] typesFromReferencedAssembly)
        {
            Guard.AgainstNullArgument("typeFromReferencedAssembly", typesFromReferencedAssembly);
            var paths = typesFromReferencedAssembly.Select(t => t.Assembly.Location);

            executor.AddReferences(paths.ToArray());
        }
Ejemplo n.º 3
0
        public ScriptResult Execute(string script)
        {
            _exec.AddReferences(typeof(Percentage));
            _exec.AddReferenceAndImportNamespaces(new [] { typeof(PackageBuilder), GetType(), typeof(RequiredAttribute) });
            _exec.ImportNamespaces("System.Linq", "CavemanTools");

            _exec.Initialize(new string[0], new IScriptPack[0]);
            return(_exec.ExecuteScript(GetScriptContent(script)));
        }
Ejemplo n.º 4
0
        public object Execute(IScriptExecutor repl, object[] args)
        {
            if (args == null || args.Length == 0)
            {
                return null;
            }

            string version = null;
            var allowPre = false;
            if (args.Length >= 2)
            {
                version = args[1].ToString();
            }

            allowPre = args.Length >= 3 && args[2].ToString().ToUpperInvariant() == "PRE";

            _logger.InfoFormat("Installing {0}", args[0]);

            _installationProvider.Initialize();

            var packageRef = new PackageReference(
                args[0].ToString(), new FrameworkName(".NETFramework,Version=v4.0"), version);

            _packageInstaller.InstallPackages(new[] { packageRef }, allowPre);
            _packageAssemblyResolver.SavePackages();

            var dlls = _packageAssemblyResolver.GetAssemblyNames(repl.FileSystem.CurrentDirectory)
                .Except(repl.References.PathReferences).ToArray();

            if(repl is IReplExecutor)
                ((IReplExecutor)repl).AddReferencesAndNotify(dlls);
            else
                repl.AddReferences(dlls);

            foreach (var dll in dlls)
            {
                _logger.InfoFormat("Added reference to {0}", dll);
            }

            return null;
        }
Ejemplo n.º 5
0
        public object Execute(IScriptExecutor repl, object[] args)
        {
            Guard.AgainstNullArgument("repl", repl);

            if (args == null || args.Length == 0)
            {
                return(null);
            }

            string version  = null;
            var    allowPre = false;

            if (args.Length >= 2)
            {
                version = args[1].ToString();
            }

            allowPre = args.Length >= 3 && args[2].ToString().ToUpperInvariant() == "PRE";

            _logger.InfoFormat("Installing {0}", args[0]);

            _installationProvider.Initialize();

            var packageRef = new PackageReference(
                args[0].ToString(), new FrameworkName(".NETFramework,Version=v4.0"), version);

            _packageInstaller.InstallPackages(new[] { packageRef }, allowPre);
            _packageAssemblyResolver.SavePackages();

            var dlls = _packageAssemblyResolver.GetAssemblyNames(repl.FileSystem.CurrentDirectory)
                       .Except(repl.References.PathReferences).ToArray();

            repl.AddReferences(dlls);

            foreach (var dll in dlls)
            {
                _logger.InfoFormat("Added reference to {0}", dll);
            }

            return(null);
        }
 public static void AddReferenceAndImportNamespaces(this IScriptExecutor executor, Type[] types)
 {
     executor.AddReferences(types);
     executor.ImportNamespaces(types);
 }
 public static void AddReference <T>(this IScriptExecutor executor)
 {
     executor.AddReferences(typeof(T));
 }
        public static void AddReference <T>(this IScriptExecutor executor)
        {
            Guard.AgainstNullArgument("executor", executor);

            executor.AddReferences(typeof(T));
        }