コード例 #1
0
ファイル: CheckKataMagic.cs プロジェクト: jjaw3/quantum-katas
        /// <summary>
        /// IQ# Magic that checks that the reference implementation of a Kata's test runs successfully.
        /// </summary>
        public CheckKataMagic(IOperationResolver resolver, ICompilerService compiler, ILogger <KataMagic> logger)
        {
            this.Name          = $"%check_kata";
            this.Documentation = new Microsoft.Jupyter.Core.Documentation
            {
                Summary     = "Checks the reference implementation for a single kata's test.",
                Description =
                    "Substitutes the reference implementation for a " +
                    "single task into the cell, and reports whether the test " +
                    "passed successfully using the reference implementation.",
                Examples = new []
                {
                    "To check a test called `Test`:\n" +
                    "```\n" +
                    "In []: %check_kata T101_StateFlip \n",
                    "  ...: operation StateFlip (q : Qubit) : Unit is Adj + Ctl {\n",
                    "           // The Pauli X gate will change the |0⟩ state to the |1⟩ state and vice versa.\n",
                    "           // Type X(q);\n",
                    "           // Then run the cell using Ctrl/⌘+Enter.\n",
                    "\n",
                    "           // ...\n",
                    "       }\n" +
                    "Out[]: Success!" +
                    "```\n"
                }
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Compiler = compiler;
            this.Logger   = logger;
        }
コード例 #2
0
 public CompileCodeCommandHandler(ELearningDbContext context, ICompilerService compiler, IFileSaveService filesave)
 {
     _context  = context;
     _compiler = compiler;
     _filesave = filesave;
     _now      = DateTime.Now;
 }
コード例 #3
0
        /// <summary>
        /// Create compiler. Start Message handler thread. Send ready message to
        /// the mother builder process. Put main thread to sleep.
        /// </summary>
        public void Start()
        {
            this.StartListener(this.config);
            if (!Directory.Exists(this.baseStorageFolder))
            {
                this.baseStorageFolder = Directory.CreateDirectory(this.baseStorageFolder).FullName;
            }
            else
            {
                this.baseStorageFolder = Path.GetFullPath(this.baseStorageFolder);
            }

            //CompilerServices.CompilerFactory.host = this.commObject;
            this.compilerService = new CSharpCompiler(this.commObject, base.defaultConfigs);
            Console.WriteLine("\n\nChild builder process started at : " + this.config.ServiceURL);
            var com = new CommMessage(CommMessage.MessageType.Request)
            {
                Command = CommCommands.READY,
                To      = base.defaultConfigs[Identity.MotherProcess].ServiceURL
            };

            this.compilerService.ExecuteCommCommand(com);
            while (!shutDown)
            {
                lock (wakeMeUp)
                {
                    //  Main thread sleeping till child process shutdown is called.
                    //  Use the main thread to process any other events. For now
                    //  all the processing is with Compiler so main thread is not
                    //  doing anything.
                    Monitor.Wait(wakeMeUp);
                }
            }
        }
コード例 #4
0
        public EngineConfiguration(
            IActivator activator,
            IRazorTemplateCompiler razorTemplateCompiler,
            ICompilerService compilerService)
        {
            if (activator == null)
            {
                throw new ArgumentNullException(nameof(activator));
            }

            if (razorTemplateCompiler == null)
            {
                throw new ArgumentNullException(nameof(razorTemplateCompiler));
            }

            if (compilerService == null)
            {
                throw new ArgumentNullException(nameof(compilerService));
            }


            this.Activator             = activator;
            this.RazorTemplateCompiler = razorTemplateCompiler;
            this.CompilerService       = compilerService;

            this.Namespaces         = new HashSet <string>();
            this.PreRenderCallbacks = new PreRenderActionList();
        }
コード例 #5
0
 public LsOpenMagic(ICompilerService compiler) : base(
         "lsopen",
         new Documentation
 {
     Summary     = "Lists currently opened namespaces and their aliases.",
     Description = @"
             This magic command lists any namespaces that have been made
             available using `open` statements, along with any aliases
             that may have been assigned to those namespaces.
         ".Dedent(),
     Examples    = new []
     {
         @"
                 Print a list of all currently opened namespaces:
                 ```
                 In []: %lsopen
                 Out[]: Namespace                     Alias
                        ----------------------------- ----
                        Microsoft.Quantum.Canon
                        Microsoft.Quantum.Diagnostics Diag
                        Microsoft.Quantum.Intrinsic
                 ```
             ".Dedent()
     }
 })
 {
     this.Compiler = compiler;
 }
コード例 #6
0
        public BaseDocument(Scope scope)
        {
            _scope    = new Scope(scope);
            _compiler = _scope.GetService <TToken, TNode, TModel>();

            //setup the node repository
            //td: per document?
            _scope.set <IDictionary <int, Scope> >(new Dictionary <int, Scope>());
        }
コード例 #7
0
        public Snippets(ICompilerService compiler, IWorkspace workspace, IReferences references, ILogger <Snippets> logger)
        {
            Compiler         = compiler;
            Workspace        = workspace;
            GlobalReferences = references;
            Logger           = logger;
            AssemblyInfo     = new AssemblyInfo(null);
            Items            = new Snippet[0];

            AssemblyLoadContext.Default.Resolving += Resolve;
        }
コード例 #8
0
        /// <summary>
        /// Override this method to define how to prepare the command on the
        /// main thread of Visual Studio
        /// </summary>
        protected override async Task ExecuteOnMainThreadAsync()
        {
            await base.ExecuteOnMainThreadAsync();

            if (IsCancelled)
            {
                return;
            }

            // --- Get the item
            GetItem(out _hierarchy, out _itemId);
            if (_hierarchy == null || !(_hierarchy is IVsProject project))
            {
                IsCancelled = true;
                return;
            }

            project.GetMkDocument(_itemId, out _itemFullPath);
            var extension = Path.GetExtension(_itemFullPath);

            _compiler = null;
            switch (extension?.ToLower())
            {
            case ".z80asm":
                _compiler = new Z80AssemblyCompiler();
                break;

            case ".zxbas":
                _compiler = new ZxBasicCompiler();
                break;
            }

            // --- Insist to have a compiler
            if (_compiler == null)
            {
                IsCancelled = true;
                return;
            }

            // --- Check that the compiler has been installed
            if (!await _compiler.IsAvailable())
            {
                IsCancelled = true;
                return;
            }

            // --- Sign that the compilation is in progress, and there
            // --- in no compiled output yet
            HostPackage.ErrorList.Clear();
            HostPackage.CompilationInProgress            = true;
            HostPackage.DebugInfoProvider.CompiledOutput = null;
            HostPackage.ApplicationObject.ExecuteCommand("File.SaveAll");
        }
コード例 #9
0
        /// <summary>
        /// Execute the build requests.
        /// </summary>
        /// <param name="buildRequest"></param>
        public void ProcessBuildRequest(BuildRequestDO buildRequest)
        {
            ICompilerService compiler = CompilerFactory.GetCompiler(buildRequest.Language);

            if (compiler != null)
            {
                compiler.Compile(buildRequest);
            }
            else
            {
                Console.WriteLine("Compiler Language not supported.");
            }
        }
コード例 #10
0
        /// <summary>
        /// IQ# Magic that checks that the reference implementation of a Kata's test runs successfully.
        /// </summary>
        public CheckKataMagic(IOperationResolver resolver, ICompilerService compiler, ILogger <KataMagic> logger)
        {
            this.Name          = $"%check_kata";
            this.Documentation = new Documentation()
            {
                Summary = "Checks the resference implementaiton of a single kata's test."
            };
            this.Kind    = SymbolKind.Magic;
            this.Execute = this.Run;

            this.Resolver = resolver;
            this.Compiler = compiler;
            this.Logger   = logger;
        }
コード例 #11
0
ファイル: Snippets.cs プロジェクト: yazici/iqsharp
        public Snippets(ICompilerService compiler, IWorkspace workspace, IReferences references, ILogger <Snippets> logger)
        {
            Compiler         = compiler;
            Workspace        = workspace;
            GlobalReferences = references;
            Logger           = logger;
            AssemblyInfo     = new AssemblyInfo(null);
            Items            = new Snippet[0];

            _metadata                       = new Lazy <CompilerMetadata>(LoadCompilerMetadata);
            Workspace.Reloaded             += OnWorkspaceReloaded;
            GlobalReferences.PackageLoaded += OnGlobalReferencesPackageLoaded;;

            AssemblyLoadContext.Default.Resolving += Resolve;
        }
コード例 #12
0
        /// <summary>
        /// Initialises a new instance of <see cref="ICompilerService"/>.
        /// </summary>
        /// <param name="compilerService">The compiler service used to generate types.</param>
        /// <param name="templateType">The template base type.</param>
        public TemplateService(ICompilerService compilerService, Type templateType = null)
        {
            if (compilerService == null)
            {
                throw new ArgumentNullException("compilerService");
            }

            this.activator       = new DefaultActivator();
            this.compilerService = compilerService;
            this.templateType    = templateType;

            Namespaces = new HashSet <string> {
                "System", "System.Collections.Generic", "System.Linq"
            };
        }
コード例 #13
0
        public EntryPointGenerator(
            ICompilerService compiler,
            IWorkspace workspace,
            ISnippets snippets,
            IReferences references,
            ILogger <EntryPointGenerator> logger,
            IEventService eventService)
        {
            Compiler   = compiler;
            Workspace  = workspace;
            Snippets   = snippets;
            References = references;
            Logger     = logger;

            AssemblyLoadContext.Default.Resolving += Resolve;

            eventService?.TriggerServiceInitialized <IEntryPointGenerator>(this);
        }
コード例 #14
0
ファイル: ExpressionHelper.cs プロジェクト: zishe/StockSharp
        /// <summary>
        /// Compile mathematical formula.
        /// </summary>
        /// <param name="service">Compiler service.</param>
        /// <param name="expression">Text expression.</param>
        /// <param name="useSecurityIds">Use security ids as variables.</param>
        /// <returns>Compiled mathematical formula.</returns>
        public static ExpressionFormula Compile(this ICompilerService service, string expression, bool useSecurityIds)
        {
            try
            {
                var code   = Escape(expression, useSecurityIds, out var securityIds);
                var result = service.GetCompiler(CompilationLanguages.CSharp).Compile("IndexExpression", _template.Replace("__insert_code", code), new[] { typeof(object).Assembly.Location, typeof(ExpressionFormula).Assembly.Location, typeof(MathHelper).Assembly.Location });

                var formula = result.Assembly == null
                                        ? new ErrorExpressionFormula(result.Errors.Where(e => e.Type == CompilationErrorTypes.Error).Select(e => e.Message).Join(Environment.NewLine))
                                        : result.Assembly.GetType("TempExpressionFormula").CreateInstance <ExpressionFormula>(expression, securityIds);

                return(formula);
            }
            catch (Exception ex)
            {
                return(new ErrorExpressionFormula(ex.ToString()));
            }
        }
コード例 #15
0
        public ProblemViewModel(MainViewModel mainViewModel, string problemPath)
        {
            _mainViewModel = mainViewModel;
            ProblemPath = problemPath;
            _testsPath = Path.ChangeExtension(ProblemPath, "txt");
            CompilerExecutablePath = Path.Combine(Path.GetTempPath(), string.Format("{0}.exe", Path.GetFileNameWithoutExtension(problemPath)));

            State = new StateViewModel();
            Tests = new ObservableCollection<TestViewModel>();

            FileChangesTracker.Instance.FileChanged += Instance_FileChanged;

            _compiler = CompilerSelector.Instance.GetCompiler(this);

            UpdateSource()
                .OnComplete(res =>
                    {
                        if (res == null) UpdateTests();
                    });
        }
コード例 #16
0
        private static Func <MatchResultBuilder, Scope, bool> MatchIdentifier(string named = null, bool matchNone = false, bool matchDocumentStart = false)
        {
            return((match, scope) =>
            {
                ICompilerService <TToken, TNode, TModel> compiler = scope.GetService <TToken, TNode, TModel>();
                if (compiler.isIdentifier(match.Peek()))
                {
                    match.AddResult(1, named);
                    return true;
                }

                if (matchNone || (matchDocumentStart && match.isDocumentStart()))
                {
                    match.AddResult(0, named);
                    return true;
                }

                return false;
            });
        }
コード例 #17
0
        public SettingsFormViewModel(IOrganizationServiceContextGenerator contextGenerator, ICompilerService compilerService, IConnectionStringService connectionStringService, Dispatcher dispatcher)
        {
            CommandGenerateDll        = new RealyAsyncCommand <object>(GenerateDllClicked, CanGenerateDllClicked);
            CommandSelectDll          = new RelayCommand(SelectDllClicked);
            CommandSelectClass        = new RealyAsyncCommand <object>(SelectClassClicked, CanSelectClassClicked);
            CommandConfirmSettings    = new RelayCommand <System.Windows.Window>(ConfirmSettingsClicked, ConfirmSettiingsCanExecute);
            CommandOpenGenerateDllLog = new RelayCommand(OpenGenerateDllLogClicked);
            CommandOpenCompileDllLog  = new RelayCommand(OpenCompileDllLog);
            CommandCancelSettings     = new RelayCommand <System.Windows.Window>(CancelSettingsClicked);
            CommandLoginToCrm         = new RelayCommand(CommandLoginToCrmClicked);

            this.contextGenerator = contextGenerator;

            contextGenerator.OutputDataReceived += (sender, args) =>
            {
                GeneratorOutput.AppendLine(args.Data);
                dispatcher.Invoke(DispatcherPriority.Normal,
                                  new System.Action(() =>
                {
                    RaisePropertyChangedEvent(nameof(GeneratorOutput));
                }
                                                    ));
            };

            contextGenerator.ErrorDataReceived += (sender, args) =>
            {
                GeneratorOutput.AppendLine(args.Data);
                dispatcher.Invoke(DispatcherPriority.Normal,
                                  new System.Action(() =>
                {
                    RaisePropertyChangedEvent(nameof(GeneratorOutput));
                }
                                                    ));
            };

            this.compilerService         = compilerService;
            this.connectionStringService = connectionStringService;
        }
コード例 #18
0
 public InterpreterProcessorService(ICompilerService compilerService)
 {
     ListKeywords     = new List <Keyword>();
     _compilerService = compilerService;
 }
コード例 #19
0
        public void CompileAssemblyAsync(string outputAssemblyName, string[] sourceContent, string[] referenceAssemblies, Action <Assembly, Exception> callback, params string[] resourceFiles)
        {
            if (this.CompilerService == null)
            {
                try
                {
                    this.EnsureTempDirectoriesExist();

                    string outputFile = Path.Combine(this.TempAssemblyDirectory, outputAssemblyName + ".dll");
                    this.Logger.WriteLine(LogLevel.Trace, "Compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputFile, referenceAssemblies.Length);

                    string[] resolvedReferenceAssemblies = this.ResolveReferenceAssemblies(referenceAssemblies);
                    this.CompileAssemblyFromSource(outputFile, sourceContent, resolvedReferenceAssemblies, resourceFiles);

                    var uniqueReferenceAssemblies = resolvedReferenceAssemblies
                                                    .Select(c => Path.GetDirectoryName(c))
                                                    .Concat(new[] { this.TempAssemblyDirectory })
                                                    .Where(c => !string.IsNullOrEmpty(c))
                                                    .Distinct()
                                                    .ToArray();

                    var assembly = AssemblyHelpers.LoadAssembly(outputFile, uniqueReferenceAssemblies);
                    callback(assembly, null);
                }
                catch (Exception ex)
                {
                    callback(null, ex);
                }

                return;
            }

            try
            {
                if (resourceFiles != null && resourceFiles.Length > 0)
                {
                    callback(null, new TaupoArgumentException("cannot handle compiling embedded resources, resource files should not be specified. "));
                    return;
                }

                ICompilerService client = this.CreateRemoteCompiler();

                this.Logger.WriteLine(LogLevel.Trace, "Remotely compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputAssemblyName, referenceAssemblies.Length);
                foreach (var refAsm in referenceAssemblies)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", refAsm);
                }

                client.BeginCompileAssembly(
                    this.RemoteCompilerType,
                    this.FileExtension,
                    this.ProjectFileExtension,
                    outputAssemblyName,
                    sourceContent,
                    referenceAssemblies,
                    result =>
                {
                    try
                    {
                        string errorLog;
                        byte[] assemblyBytes = client.EndCompileAssembly(out errorLog, result);
                        if (assemblyBytes == null)
                        {
                            callback(null, new TaupoInvalidOperationException("Error compiling assembly: " + errorLog));
                            return;
                        }

                        string cachePath = Path.Combine(this.TempAssemblyDirectory, outputAssemblyName + ".dll");
                        this.EnsureTempDirectoriesExist();

                        File.WriteAllBytes(cachePath, assemblyBytes);
                        var assembly = AssemblyHelpers.LoadAssembly(cachePath, this.TempAssemblyDirectory);
                        callback(assembly, null);
                    }
                    catch (Exception ex)
                    {
                        callback(null, ex);
                    }
                },
                    null);
            }
            catch (Exception ex)
            {
                callback(null, ex);
            }
        }
コード例 #20
0
 public SolutionController(IDbRepository setupRepository, ICompilerService setupCompilerService)
 {
     this.setupRepository = setupRepository;
     this.compilerService = setupCompilerService;
 }
コード例 #21
0
 public UnitTestController(IDbRepository setupRepository, ITestGenarator testGenerator, ICompilerService unitTestCompilerService)
 {
     this.dbRepository = setupRepository;
     this.testGenerator = testGenerator;
     this.compilerService = unitTestCompilerService;
 }
コード例 #22
0
        public void CompileAssemblyFromSource(string outputFile, string[] sourceContent, string[] referenceAssemblies, params string[] resourceFiles)
        {
            referenceAssemblies = referenceAssemblies ?? new string[0];

            if (this.CompilerService != null)
            {
                // invoke remote compiler synchronously
                ICompilerService client = this.CreateRemoteCompiler();
                string           errorLog;

                string outputName = Path.GetFileNameWithoutExtension(outputFile);

                this.Logger.WriteLine(LogLevel.Trace, "Remotely compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputName, referenceAssemblies.Length);
                foreach (var refAsm in referenceAssemblies)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", refAsm);
                }

                byte[] assemblyBytes = client.CompileAssembly(out errorLog, this.RemoteCompilerType, this.FileExtension, this.ProjectFileExtension, outputFile, sourceContent, referenceAssemblies);
                if (assemblyBytes == null)
                {
                    throw new TaupoInvalidOperationException("Errors during compilation:\r\n\r\n" + errorLog);
                }

                File.WriteAllBytes(outputFile, assemblyBytes);
            }
            else
            {
                CodeDomProvider    codeProvider = this.CreateCodeProvider();
                CompilerParameters parameters   = new CompilerParameters();

                string[] resolvedReferenceAssemblies = this.ResolveReferenceAssemblies(referenceAssemblies);
                parameters.ReferencedAssemblies.AddRange(resolvedReferenceAssemblies);

                parameters.WarningLevel            = 4;
                parameters.OutputAssembly          = outputFile;
                parameters.IncludeDebugInformation = !this.IsReleaseBuild;
                parameters.CompilerOptions         = this.IsReleaseBuild ? "/optimize" : null;

                List <string> fileNames = new List <string>();
                this.EnsureTempDirectoriesExist();

                foreach (var source in sourceContent)
                {
                    string tempFileName = Path.GetFullPath(Path.Combine(this.TempSourceFileDirectory, Guid.NewGuid().ToString("N") + this.FileExtension));
                    File.WriteAllText(tempFileName, source);
                    fileNames.Add(tempFileName);
                }

                foreach (var resource in resourceFiles)
                {
                    parameters.EmbeddedResources.Add(resource);
                }

                this.Logger.WriteLine(LogLevel.Trace, "Compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputFile, referenceAssemblies.Length);
                this.Logger.WriteLine(LogLevel.Trace, "Source files:");
                foreach (var sourceFile in fileNames)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", sourceFile);
                }

                this.Logger.WriteLine(LogLevel.Trace, "Embedded resource files:");
                foreach (var resource in resourceFiles)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", resource);
                }

                this.Logger.WriteLine(LogLevel.Trace, "Reference assemblies:");
                foreach (var refAsm in referenceAssemblies)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", refAsm);
                }

                var results = codeProvider.CompileAssemblyFromFile(parameters, fileNames.ToArray());
                if (results.Errors.HasErrors)
                {
                    throw new TaupoInvalidOperationException(this.GetExceptionText(results));
                }
            }
        }
コード例 #23
0
        public void CompileAssemblyAsync(string outputAssemblyName, string[] sourceContent, string[] referenceAssemblies, Action <Assembly, Exception> callback, params string[] resourceFiles)
        {
#if WINDOWS_PHONE
            throw new TaupoNotSupportedException("This method is not supported on the Windows Phone platform");
#endif
#if !SILVERLIGHT
            if (this.CompilerService == null)
            {
                try
                {
                    this.EnsureTempDirectoriesExist();

                    string outputFile = Path.Combine(this.TempAssemblyDirectory, outputAssemblyName + ".dll");
                    this.Logger.WriteLine(LogLevel.Trace, "Compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputFile, referenceAssemblies.Length);

                    string[] resolvedReferenceAssemblies = this.ResolveReferenceAssemblies(referenceAssemblies);
                    this.CompileAssemblyFromSource(outputFile, sourceContent, resolvedReferenceAssemblies, resourceFiles);

                    var uniqueReferenceAssemblies = resolvedReferenceAssemblies
                                                    .Select(c => Path.GetDirectoryName(c))
                                                    .Concat(new[] { this.TempAssemblyDirectory })
                                                    .Where(c => !string.IsNullOrEmpty(c))
                                                    .Distinct()
                                                    .ToArray();

                    var assembly = AssemblyHelpers.LoadAssembly(outputFile, uniqueReferenceAssemblies);
                    callback(assembly, null);
                }
                catch (Exception ex)
                {
                    callback(null, ex);
                }

                return;
            }
#endif
#if !WINDOWS_PHONE
            try
            {
                if (resourceFiles != null && resourceFiles.Length > 0)
                {
                    callback(null, new TaupoArgumentException("cannot handle compiling embedded resources, resource files should not be specified. "));
                    return;
                }

                ICompilerService client = this.CreateRemoteCompiler();

                this.Logger.WriteLine(LogLevel.Trace, "Remotely compiling {0} files to {1} using {2} reference assemblies:", sourceContent.Length, outputAssemblyName, referenceAssemblies.Length);
                foreach (var refAsm in referenceAssemblies)
                {
                    this.Logger.WriteLine(LogLevel.Trace, "   {0}", refAsm);
                }

#if WIN8
                var compileAssemblyRequest = new CompileAssemblyRequest
                {
                    outputAssemblyName   = outputAssemblyName,
                    projectFileExtension = this.ProjectFileExtension,
                    projectType          = this.RemoteCompilerType,
                    referenceAssemblies  = new System.Collections.ObjectModel.ObservableCollection <string>(referenceAssemblies),
                    sourceFileExtension  = this.FileExtension,
                    sources = new System.Collections.ObjectModel.ObservableCollection <string>(sourceContent),
                };

                var compileAssemblyTask = client.CompileAssemblyAsync(compileAssemblyRequest);
                compileAssemblyTask.Wait();
                var    compileAssemblyResponse = compileAssemblyTask.Result;
                byte[] assemblyBytes           = compileAssemblyResponse.CompileAssemblyResult;
                if (assemblyBytes == null)
                {
                    callback(null, new TaupoInvalidOperationException("Error compiling assembly: " + compileAssemblyResponse.errorLog));
                    return;
                }

                Assembly clientTypesAssembly = this.LoadDynamicAssembly(assemblyBytes);
                callback(clientTypesAssembly, null);
#else
                client.BeginCompileAssembly(
                    this.RemoteCompilerType,
                    this.FileExtension,
                    this.ProjectFileExtension,
                    outputAssemblyName,
                    sourceContent,
                    referenceAssemblies,
                    result =>
                {
                    try
                    {
                        string errorLog;
                        byte[] assemblyBytes = client.EndCompileAssembly(out errorLog, result);
                        if (assemblyBytes == null)
                        {
                            callback(null, new TaupoInvalidOperationException("Error compiling assembly: " + errorLog));
                            return;
                        }

#if SILVERLIGHT
                        System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            Assembly clientTypesAssembly = this.LoadDynamicAssembly(assemblyBytes);
                            callback(clientTypesAssembly, null);
                        });
#else
                        string cachePath = Path.Combine(this.TempAssemblyDirectory, outputAssemblyName + ".dll");
                        this.EnsureTempDirectoriesExist();

                        File.WriteAllBytes(cachePath, assemblyBytes);
                        var assembly = AssemblyHelpers.LoadAssembly(cachePath, this.TempAssemblyDirectory);
                        callback(assembly, null);
#endif
                    }
                    catch (Exception ex)
                    {
                        callback(null, ex);
                    }
                },
                    null);
#endif
            }
            catch (Exception ex)
            {
                callback(null, ex);
            }
#endif
        }
コード例 #24
0
 public InterpreterProcessorServiceFactory()
 {
     _configurationMock          = mockConfig();
     _compilerService            = new CompilerService(_configurationMock.Object);
     InterpreterProcessorService = new InterpreterProcessorService(_compilerService);
 }