コード例 #1
0
ファイル: Assemblies.CLR.cs プロジェクト: dw4dev/Phalanger
		internal override void LoadCompileTimeReferencedAssemblies(AssemblyLoader/*!*/ loader)
		{
			base.LoadCompileTimeReferencedAssemblies(loader);

			foreach (string full_name in GetAttribute().ReferencedAssemblies)
				loader.Load(full_name, null, null);
		}
コード例 #2
0
		public static void InitializeDatabase(
            AssemblyLoader assemblyLoader, 
            string contextAssemblyPath, 
            string contextName, 
            string serverName,
			string databaseName)
		{
			assemblyLoader.Load(MigrationsSource.Deployed, contextAssemblyPath);

			using (
				var context =
					Assembly.LoadFile(contextAssemblyPath).CreateInstance(contextName) as DbContext)
			{
				context.Database.Connection.ConnectionString=
					string.Format(
						"Server={0};Initial Catalog={1};Integrated Security=true;Application Name=Galen.Ci.EntityFramework.Tests;",
						serverName, databaseName);
				context.Database.Initialize(false);
			}
		}
コード例 #3
0
        public OperationExecutor(
            [NotNull] CommonOptions options,
            [CanBeNull] string environment)
        {
            if (!string.IsNullOrEmpty(options.DataDirectory))
            {
                Environment.SetEnvironmentVariable(DataDirEnvName, options.DataDirectory);
#if NET451
                AppDomain.CurrentDomain.SetData("DataDirectory", options.DataDirectory);
#endif
            }

            if (!File.Exists(options.Assembly))
            {
                throw new OperationException($"Could not find assembly '{options.Assembly}'.");
            }

            var assemblyFileName = Path.GetFileNameWithoutExtension(options.Assembly);
            
            // TODO add hooks into Assembly.Load to allow loading from other locations
            var assemblyLoader = new AssemblyLoader(Assembly.Load);
            var projectAssembly = assemblyLoader.Load(assemblyFileName);

            // optional
            var startupAssembly = string.IsNullOrWhiteSpace(options.StartupAssembly)
                ? projectAssembly
                : assemblyLoader.Load(Path.GetFileNameWithoutExtension(options.StartupAssembly));

            var projectDir = string.IsNullOrEmpty(options.ProjectDirectory)
                ? Directory.GetCurrentDirectory()
                : options.ProjectDirectory;

            var contentRootPath = string.IsNullOrEmpty(options.ContentRootPath)
#if NET451
                ? AppDomain.CurrentDomain.GetData("APP_CONTEXT_BASE_DIRECTORY") as string ?? AppDomain.CurrentDomain.BaseDirectory
#else
                ? AppContext.BaseDirectory
#endif
                : options.ContentRootPath;

            var rootNamespace = string.IsNullOrEmpty(options.RootNamespace)
                ? assemblyFileName
                : options.RootNamespace;

            _contextOperations = new LazyRef<DbContextOperations>(
                () => new DbContextOperations(
                    new LoggerProvider(name => new ConsoleCommandLogger(name)),
                    assembly: projectAssembly,
                    startupAssembly: startupAssembly,
                    environment: environment,
                    contentRootPath: contentRootPath));
            _databaseOperations = new LazyRef<DatabaseOperations>(
                () => new DatabaseOperations(
                    new LoggerProvider(name => new ConsoleCommandLogger(name)),
                    startupAssemblyLoader: assemblyLoader,
                    startupAssembly: startupAssembly,
                    environment: environment,
                    projectDir: projectDir,
                    contentRootPath: contentRootPath,
                    rootNamespace: rootNamespace));
            _migrationsOperations = new LazyRef<MigrationsOperations>(
                () => new MigrationsOperations(
                    new LoggerProvider(name => new ConsoleCommandLogger(name)),
                    assembly: projectAssembly,
                    startupAssemblyLoader: assemblyLoader,
                    startupAssembly: startupAssembly,
                    environment: environment,
                    projectDir: projectDir,
                    contentRootPath: contentRootPath,
                    rootNamespace: rootNamespace));
        }