MS.Ext.DI中任何可能在编译时获取基于lmlementationType的描述符

时间:2017-06-01 18:54:28

标签: c# dependency-injection asp.net-core ioc-container dryioc

我想为Microsoft.Extensions.DependencyInjection创建一个适配器,以便在可能的情况下将基于类型的注册移动到编译时。例如,在Asp .Net Core中,这意味着我需要在编译时以某种方式获得基于// Will be used to track word counting const arrWords = []; // Target string const str = 'fsdf this is the article fsdf we are targeting'; // We split each word in one array const arrStr = str.trim().split(' '); // Lets iterate over the words const iterate = arrStr.forEach(word => { // if a new word, lets track it by pushing to arrWords if (!arrWords.includes(word)) { arrWords.push({ word: word, count: 1 }); } else { // if the word is being tracked, and we come across the same word, increase the property "count" by 1 const indexOfTrackedWord = arrWords.indexOf(word); arrWords[indexOfTrackedWord].count++; } }); // Once that forEach function is done, you now have an array of objects that look like this for each word: arrWords: [ { word: 'fsdf', count: 2 }, { word: 'this', count: 1 }, // etc etc for the other words in the string ]; 的描述符的服务集合

我不关心ImplementationType的运行时描述符,它可能由容器的运行时部分处理。但是类型在编译时是已知的,例如组件到位,不会改变。那么为什么不在编译时为类型构建/解析对象图来加速引导时间并获得关于如何组合类型的愿景。

顺便说一下,实现这一目标的IoC并不重要,但我会使用DryIocZero / DryIoc

0 个答案:

没有答案