当前位置: 首页>>代码示例>>C#>>正文


C# IAssemblyLoadContext类代码示例

本文整理汇总了C#中IAssemblyLoadContext的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyLoadContext类的具体用法?C# IAssemblyLoadContext怎么用?C# IAssemblyLoadContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IAssemblyLoadContext类属于命名空间,在下文中一共展示了IAssemblyLoadContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

        public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
        {
            // An assembly name like "MyLibrary!alternate!more-text"
            // is parsed into:
            // name == "MyLibrary"
            // aspect == "alternate"
            // and the more-text may be used to force a recompilation of an aspect that would
            // otherwise have been cached by some layer within Assembly.Load

            var name = assemblyName.Name;
            string aspect = null;
            var parts = name.Split(new[] { '!' }, 3);
            if (parts.Length != 1)
            {
                name = parts[0];
                aspect = parts[1];
            }

            var library = _libraryManager.GetLibraryDescription(name) as ProjectDescription;

            if (library == null)
            {
                return null;
            }

            return _compilationEngine.LoadProject(
                library.Project, 
                aspect, 
                loadContext);
        }
开发者ID:cemoses,项目名称:aspnet,代码行数:30,代码来源:ProjectAssemblyLoader.cs

示例2: TryRegisterFaultedPlugins

        public void TryRegisterFaultedPlugins(IAssemblyLoadContext assemblyLoadContext)
        {
            if (assemblyLoadContext == null)
            {
                throw new ArgumentNullException(nameof(assemblyLoadContext));
            }

            // Capture the messages here so we can clear the original list to potentially re-add messages if they
            // fail to recover.
            var faultedRegistrations = _faultedRegisterPluginMessages.ToArray();
            _faultedRegisterPluginMessages.Clear();

            foreach (var faultedRegisterPluginMessage in faultedRegistrations)
            {
                var response = RegisterPlugin(faultedRegisterPluginMessage, assemblyLoadContext);

                if (response.Success)
                {
                    SendMessage(faultedRegisterPluginMessage.PluginId, response);
                }
                else
                {
                    // We were unable to recover, re-add the faulted register plugin message.
                    _faultedRegisterPluginMessages.Add(faultedRegisterPluginMessage);
                }
            }
        }
开发者ID:leloulight,项目名称:dnx,代码行数:27,代码来源:PluginHandler.cs

示例3: LibraryExporter

 public LibraryExporter(LibraryManager manager, IAssemblyLoadContext loadContext, CompilationEngine compilationEngine, string configuration)
 {
     LibraryManager = manager;
     _compilationEngine = compilationEngine;
     _configuration = configuration;
     _loadContext = loadContext;
 }
开发者ID:cemoses,项目名称:aspnet,代码行数:7,代码来源:LibraryExporter.cs

示例4: Load

        public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
        {
            // An assembly name like "MyLibrary!alternate!more-text"
            // is parsed into:
            // name == "MyLibrary"
            // aspect == "alternate"
            // and the more-text may be used to force a recompilation of an aspect that would
            // otherwise have been cached by some layer within Assembly.Load

            var name = assemblyName.Name;
            string aspect = null;
            var parts = name.Split(new[] { '!' }, 3);
            if (parts.Length != 1)
            {
                name = parts[0];
                aspect = parts[1];
            }

            Project project;
            if (!_projectResolver.TryResolveProject(name, out project))
            {
                return null;
            }

            return _compilationEngine.LoadProject(
                project,
                aspect,
                loadContext);
        }
开发者ID:henghu-bai,项目名称:dnx,代码行数:29,代码来源:ProjectAssemblyLoader.cs

示例5: LoadAssembly

        /// <summary>
        /// Loads the assembly containing precompiled views. 
        /// </summary>
        /// <param name="loadContext">The <see cref="IAssemblyLoadContext"/>.</param>
        /// <returns>The <see cref="Assembly"/> containing precompiled views.</returns>
        public virtual Assembly LoadAssembly(IAssemblyLoadContext loadContext)
        {
            var viewCollectionAssembly = GetType().GetTypeInfo().Assembly;

            using (var assemblyStream = viewCollectionAssembly.GetManifestResourceStream(AssemblyResourceName))
            {
                if (assemblyStream == null)
                {
                    var message = Resources.FormatRazorFileInfoCollection_ResourceCouldNotBeFound(AssemblyResourceName,
                                                                                                  GetType().FullName);
                    throw new InvalidOperationException(message);
                }

                Stream symbolsStream = null;
                if (!string.IsNullOrEmpty(SymbolsResourceName))
                {
                    symbolsStream = viewCollectionAssembly.GetManifestResourceStream(SymbolsResourceName);
                }

                using (symbolsStream)
                {
                    return loadContext.LoadStream(assemblyStream, symbolsStream);
                }
            }
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:30,代码来源:RazorFileInfoCollection.cs

示例6: CompilationEngineContext

 public CompilationEngineContext(IApplicationEnvironment applicationEnvironment,
                                 IRuntimeEnvironment runtimeEnvironment,
                                 IAssemblyLoadContext defaultLoadContext,
                                 CompilationCache cache)
     : this(applicationEnvironment, runtimeEnvironment, defaultLoadContext, cache, NoopWatcher.Instance)
 {
 }
开发者ID:rajeevkb,项目名称:dnx,代码行数:7,代码来源:CompilationEngineContext.cs

示例7: CompilationEngineContext

        public CompilationEngineContext(IApplicationEnvironment applicationEnvironment,
                                        IAssemblyLoadContext defaultLoadContext,
                                        CompilationCache cache) :
            this(applicationEnvironment, defaultLoadContext, cache, NoopWatcher.Instance, new ProjectGraphProvider())
        {

        }
开发者ID:cemoses,项目名称:aspnet,代码行数:7,代码来源:CompilationEngineContext.cs

示例8: LibraryAssemblyLoadContext

 public LibraryAssemblyLoadContext(ProjectAssemblyLoader projectAssemblyLoader,
                                   NuGetAssemblyLoader nugetAssemblyLoader,
                                   IAssemblyLoadContext defaultContext)
 {
     _projectAssemblyLoader = projectAssemblyLoader;
     _nugetAssemblyLoader = nugetAssemblyLoader;
     _defaultContext = defaultContext;
 }
开发者ID:noahfalk,项目名称:dnx,代码行数:8,代码来源:AssemblyLoadContextFactory.cs

示例9: RoslynCompilationService

 public RoslynCompilationService(IApplicationEnvironment environment,
                                 IAssemblyLoadContextAccessor accessor,
                                 ILibraryExporter libraryExporter)
 {
     _environment = environment;
     _loader = accessor.GetLoadContext(typeof(RoslynCompilationService).GetTypeInfo().Assembly);
     _libraryExporter = libraryExporter;
 }
开发者ID:robbert229,项目名称:Scaffolding,代码行数:8,代码来源:RoslynCompilationService.cs

示例10: RuntimeLoadContext

 public RuntimeLoadContext(LibraryManager libraryManager,
                           ICompilationEngine compilationEngine,
                           IAssemblyLoadContext defaultContext)
 {
     _projectAssemblyLoader = new ProjectAssemblyLoader(loadContextAccessor: null, compilationEngine: compilationEngine, libraryManager: libraryManager);
     _packageAssemblyLoader = new PackageAssemblyLoader(loadContextAccessor: null, libraryManager: libraryManager);
     _defaultContext = defaultContext;
 }
开发者ID:cemoses,项目名称:aspnet,代码行数:8,代码来源:RuntimeLoadContext.cs

示例11: Load

        public Assembly Load(string name, IAssemblyLoadContext loadContext)
        {
            PackageAssembly assemblyInfo;
            if (_dependencyResolver.PackageAssemblyLookup.TryGetValue(name, out assemblyInfo))
            {
                return loadContext.LoadFile(assemblyInfo.Path);
            }

            return null;
        }
开发者ID:elanwu123,项目名称:dnx,代码行数:10,代码来源:NuGetAssemblyLoader.cs

示例12: Load

        public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
        {
            // TODO: preserve name and culture info (we don't need to look at any other information)
            PackageAssembly assemblyInfo;
            if (_dependencyResolver.PackageAssemblyLookup.TryGetValue(new AssemblyName(assemblyName.Name), out assemblyInfo))
            {
                return loadContext.LoadFile(assemblyInfo.Path);
            }

            return null;
        }
开发者ID:henghu-bai,项目名称:dnx,代码行数:11,代码来源:NuGetAssemblyLoader.cs

示例13: Load

        public Assembly Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
        {
            // TODO: preserve name and culture info (we don't need to look at any other information)
            string path;
            if (_assemblies.TryGetValue(new AssemblyName(assemblyName.Name), out path))
            {
                return loadContext.LoadFile(path);
            }

            return null;
        }
开发者ID:cemoses,项目名称:aspnet,代码行数:11,代码来源:PackageAssemblyLoader.cs

示例14: AssemblyCache

 public AssemblyCache(ILibraryManager manager,
     IAssemblyLoadContextAccessor accessor,
     IAssemblyLoaderContainer container,
     IApplicationEnvironment environment)
 {
     _libraryManager = manager;
     _environment = environment;
     _loadContext = accessor.GetLoadContext(typeof (Program).GetTypeInfo().Assembly);
     Loader = new DirectoryLookupAssemblyLoader(_loadContext);
     _loaderRegistration = container.AddLoader(Loader);
 }
开发者ID:geffzhang,项目名称:Bolt,代码行数:11,代码来源:AssemblyCache.cs

示例15: Register

        public static void Register(CommandLineApplication app, IAssemblyLoadContext assemblyLoadContext)
        {
            app.Command("resolve-taghelpers", config =>
            {
                config.Description = "Resolves TagHelperDescriptors in the specified assembly(s).";
                config.HelpOption("-?|-h|--help");
                var clientProtocol = config.Option(
                    "-p|--protocol",
                    "Provide client protocol version.",
                    CommandOptionType.SingleValue);
                var assemblyNames = config.Argument(
                    "[name]",
                    "Assembly name to resolve TagHelperDescriptors in.",
                    multipleValues: true);

                config.OnExecute(() =>
                {
                    var messageBroker = new CommandMessageBroker();
                    var plugin = new RazorPlugin(messageBroker);
                    var resolvedProtocol = ResolveProtocolCommand.ResolveProtocol(clientProtocol, plugin.Protocol);

                    plugin.Protocol = resolvedProtocol;

                    var success = true;
                    foreach (var assemblyName in assemblyNames.Values)
                    {
                        var messageData = new ResolveTagHelperDescriptorsRequestData
                        {
                            AssemblyName = assemblyName,
                            SourceLocation = SourceLocation.Zero
                        };
                        var message = new RazorPluginRequestMessage(
                            RazorPluginMessageTypes.ResolveTagHelperDescriptors,
                            JObject.FromObject(messageData));

                        success &= plugin.ProcessMessage(JObject.FromObject(message), assemblyLoadContext);
                    }

                    var resolvedDescriptors = messageBroker.Results.SelectMany(result => result.Data.Descriptors);
                    var resolvedErrors = messageBroker.Results.SelectMany(result => result.Data.Errors);
                    var resolvedResult = new ResolvedTagHelperDescriptorsResult
                    {
                        Descriptors = resolvedDescriptors,
                        Errors = resolvedErrors
                    };
                    var serializedResult = JsonConvert.SerializeObject(resolvedResult, Formatting.Indented);

                    Console.WriteLine(serializedResult);

                    return success ? 0 : 1;
                });
            });
        }
开发者ID:IlyaKhD,项目名称:RazorTooling,代码行数:53,代码来源:ResolveTagHelpersCommand.cs


注:本文中的IAssemblyLoadContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。