コード例 #1
0
ファイル: ExecutionHost.cs プロジェクト: dmetzgar/RoslynPad
            public Task Initialize(IList <string> references, IList <string> imports, NuGetConfiguration nuGetConfiguration, string workingDirectory)
            {
                var scriptOptions = _scriptOptions
                                    .WithReferences(references)
                                    .WithImports(imports);

                if (nuGetConfiguration != null)
                {
                    var resolver = new NuGetScriptMetadataResolver(nuGetConfiguration, workingDirectory);
                    scriptOptions = scriptOptions.WithMetadataResolver(resolver);
                }
                _scriptOptions = scriptOptions;

                _callbackChannel = OperationContext.Current.GetCallbackChannel <IServiceCallback>();

                return(Task.CompletedTask);
            }
コード例 #2
0
            public Task Initialize(IList <string> references, IList <string> imports, NuGetConfiguration nuGetConfiguration, string workingDirectory)
            {
                // TODO: remove this once C# 7 is finalized
                var scriptCompilerType = Type.GetType("Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScriptCompiler, Microsoft.CodeAnalysis.CSharp.Scripting", throwOnError: true);
                var optionsField       = scriptCompilerType.GetField("s_defaultOptions", BindingFlags.Static | BindingFlags.NonPublic);
                var options            = ((CSharpParseOptions)optionsField.GetValue(null)).WithPreprocessorSymbols("__DEMO__", "__DEMO_EXPERIMENTAL__");

                optionsField.SetValue(null, options);

                var scriptOptions = _scriptOptions
                                    .WithReferences(references)
                                    .WithImports(imports);

                if (nuGetConfiguration != null)
                {
                    var resolver = new NuGetScriptMetadataResolver(nuGetConfiguration, workingDirectory);
                    scriptOptions = scriptOptions.WithMetadataResolver(resolver);
                }
                _scriptOptions = scriptOptions;

                _callbackChannel = OperationContext.Current.GetCallbackChannel <IServiceCallback>();

                return(Task.CompletedTask);
            }
コード例 #3
0
 public void Initialize(IList<string> references, IList<string> imports, INuGetProvider nuGetProvider, string workingDirectory, Action<ResultObject> dumped, Action<int> completed)
 {
     var scriptOptions = _scriptOptions
         .WithReferences(references)
         .WithImports(imports);
     if (nuGetProvider != null)
     {
         var resolver = new NuGetScriptMetadataResolver(nuGetProvider, workingDirectory);
         scriptOptions = scriptOptions.WithMetadataResolver(resolver);
     }
     _scriptOptions = scriptOptions;
     _dumped = dumped;
     _completed = completed;
 }