/// <summary> /// Compiles the binding expressions in the specified content directory tree. /// </summary> /// <param name="root">The root of the content directory tree to search for binding expressions to compile.</param> /// <param name="flags">A set of <see cref="CompileExpressionsFlags"/> values specifying how the expressions should be compiled.</param> public void CompileExpressions(String root, CompileExpressionsFlags flags = CompileExpressionsFlags.None) { Contract.EnsureNotDisposed(this, Disposed); Contract.RequireNotEmpty(root, nameof(root)); if (!IsSupportedPlatform(Ultraviolet.Runtime, Ultraviolet.Platform)) { throw new NotSupportedException(); } LoadBindingExpressionCompiler(); var options = CreateCompilerOptions(root, flags); try { var result = bindingExpressionCompiler.Compile(Ultraviolet, options); if (result.Failed) { throw new BindingExpressionCompilationFailedException(result.Message, result); } inMemoryBindingExpressionsAsm = result.Assembly; } catch (Exception e) { LogExceptionToBuildOutputConsole(root, e, (flags & CompileExpressionsFlags.ResolveContentFiles) == CompileExpressionsFlags.ResolveContentFiles); throw; } GC.Collect(2, GCCollectionMode.Forced); }
/// <summary> /// Compiles the binding expressions in the specified content directory tree if the application is running /// one one of the platforms which supports doing so. Otherwise, this method has no effect. /// </summary> /// <param name="root">The root of the content directory tree to search for binding expressions to compile.</param> /// <param name="flags">A set of <see cref="CompileExpressionsFlags"/> values specifying how the expressions should be compiled.</param> public void CompileExpressionsIfSupported(String root, CompileExpressionsFlags flags = CompileExpressionsFlags.None) { Contract.EnsureNotDisposed(this, Disposed); Contract.RequireNotEmpty(root, nameof(root)); if (!IsSupportedPlatform(Ultraviolet.Runtime, Ultraviolet.Platform)) { return; } CompileExpressions(root, flags); }
/// <summary> /// Creates a new instance of the <see cref="BindingExpressionCompilerOptions"/> class from the specified set of flags. /// </summary> private static BindingExpressionCompilerOptions CreateCompilerOptions(String root, CompileExpressionsFlags flags) { var generateInMemory = (flags & CompileExpressionsFlags.GenerateInMemory) == CompileExpressionsFlags.GenerateInMemory; var options = new BindingExpressionCompilerOptions() { GenerateInMemory = generateInMemory, WriteErrorsToFile = true, Input = root, Output = CompiledExpressionsAssemblyName, IgnoreCache = generateInMemory || (flags & CompileExpressionsFlags.IgnoreCache) == CompileExpressionsFlags.IgnoreCache, WorkInTemporaryDirectory = (flags & CompileExpressionsFlags.WorkInTemporaryDirectory) == CompileExpressionsFlags.WorkInTemporaryDirectory }; return(options); }
/// <summary> /// Creates a new instance of the <see cref="BindingExpressionCompilerOptions"/> class from the specified set of flags. /// </summary> private static BindingExpressionCompilerOptions CreateCompilerOptions(String root, CompileExpressionsFlags flags) { var options = new BindingExpressionCompilerOptions() { GenerateInMemory = flags.HasFlag(CompileExpressionsFlags.GenerateInMemory), WriteErrorsToFile = true, WriteCompiledFilesToWorkingDirectory = flags.HasFlag(CompileExpressionsFlags.WriteCompiledFilesToWorkingDirectory), Input = root, Output = CompiledExpressionsAssemblyName, IgnoreCache = flags.HasFlag(CompileExpressionsFlags.GenerateInMemory) || flags.HasFlag(CompileExpressionsFlags.IgnoreCache), WorkInTemporaryDirectory = flags.HasFlag(CompileExpressionsFlags.WorkInTemporaryDirectory), }; return(options); }