Visual Studio 2017 - 如何从ENVDTE获取当前正在运行的版本(Visual Studio 2017 - How to get the current running edition from ENVDTE)
我正在开发Visual Studio 2017的VSIX包端口,我需要从VSPackage(Enterprise,Community等)获取正在运行的版本。
看看ENVDTE接口 ,获取版本号非常简单,但不是版本号。 截至2013年,至少有可能从注册表中检索已安装的版本,但似乎并非如此,因为VS2017使用了自己的私有注册表 。
有没有人有关于如何获得当前运行的Visual Studio 2017版的想法?
I'm working on a VSIX package port to Visual Studio 2017 and I need to get the running edition from the VSPackage (Enterprise, Community etc..).
Looking at the ENVDTE interface it's pretty straightforward to get the version number, but not the edition. Up to VS 2013 it was possible at least to retrieve the installed edition from the registry but it seems it's not the case anymore as VS2017 uses a its own private registry.
Does anyone have an idea on how to get the current running Visual Studio 2017 edition?
原文:https://stackoverflow.com/questions/48402898
最满意答案
不知道你是否有一些限制,但这就是我的做法。
遍历所有对象并将它们放入一个对象中。 该对象的关键将是名称。 检查对象是否存在,如果没有添加它并用
[number]
替换[number]
,如果对象已经存在,只需添加数字即可。一旦你遍历所有的对象,将该对象转换为列表,就是这样。
function groupByName(accum, obj) { if (accum[obj.name]) { // add all numbers! don't check for uniqueness yet accum[obj.name].number = accum[obj.name].concat(obj.number) } else { accum[obj.name] = obj obj.number = [obj.number] } return accum } function removeDuplicates(accum, value) { if (accum.length == 0 && accum[accum.length - 1] != value) { accum.push(value) } return accum } function toList(context) { return function (key) { var obj = context[key] obj.number.sort() obj.number = obj.number.reduce(removeDuplicates, []) return obj } } objs = arrT.reduce(groupByName, {}) output = Object.keys(objs).map(toList(objs))
请注意,我正在编辑第一个对象,所以如果这些对象在其他地方没有用处,那就好了......如果不是,您应该复制reduce函数而不是修改现有对象。
Not sure if you have some constraints but that's how I'd do it.
Loop over all of your object and put them into an object. The key of the object will be the name. Check if the object exists, if it doesn't add it and replace the
number
by[number]
, if the object already exists, simply add the number withpush
.Once you looped over all your objects, convert that object to a list and that's it.
function groupByName(accum, obj) { if (accum[obj.name]) { // add all numbers! don't check for uniqueness yet accum[obj.name].number = accum[obj.name].concat(obj.number) } else { accum[obj.name] = obj obj.number = [obj.number] } return accum } function removeDuplicates(accum, value) { if (accum.length == 0 && accum[accum.length - 1] != value) { accum.push(value) } return accum } function toList(context) { return function (key) { var obj = context[key] obj.number.sort() obj.number = obj.number.reduce(removeDuplicates, []) return obj } } objs = arrT.reduce(groupByName, {}) output = Object.keys(objs).map(toList(objs))
Note that I'm ediding the first object so if there is no use for those objects anywhere else, that's fine... if not, you should copy in the reduce function instead of modifying and existing object.
相关问答
更多-
使用jQuery(或Javascript)将对象列表推送到数组中(Push A List of Objects Into an Array Using jQuery (Or Javascript))[2022-02-24]
您的代码完全符合您的要求,但您检查了错误的变量: var images = ["A", "B", "C"] console.log(images); src = []; data = {} for (var i = 0; i < images.length; i++) { data = { src: images[i] }; // Here data is an object with 1 key only. src.push(data); } // He ... -
如果你只推入一次ticketsToAdd数组, 使用, for(var i=0; i<5; i++) { ticketsToAdd[0]['Attendees'].push({ "EmailID": "", "Phone": "", "FirstName": "", "LastName": "", "Company": "" }) } ...
-
如何在空数组中推送对象(How to push object in empty array)[2022-05-26]
story.scenarios在一开始就是null所以你需要将它初始化为[]但是你不想一直这样做,因为story.scenarios可能已经有了数据。 story.scenarios = story.scenarios || []; story.scenarios.push(req.body); The story.scenarios is null at the very beginning so you need to initialize it as [] but you don't want t ... -
不知道你是否有一些限制,但这就是我的做法。 遍历所有对象并将它们放入一个对象中。 该对象的关键将是名称。 检查对象是否存在,如果没有添加它并用[number]替换[number] ,如果对象已经存在,只需添加数字即可。 一旦你遍历所有的对象,将该对象转换为列表,就是这样。 function groupByName(accum, obj) { if (accum[obj.name]) { // add all numbers! don't check for uniqueness yet ...
-
对于未初始化为任何对象的对象,null是一个特殊值。 我的猜测是localStorage.getItem('session')是空的。 一个更健壮的答案会是这样的 function SaveDataToLocalStorage(data) { var a; //is anything in localstorage? if (localStorage.getItem('session') === null) { a = []; } else { ...
-
您可以借助d3.sum采取功能性方法... obj.push(d3.keys(obj[0]) //get the keys from obj[0] .reduce(function(sumRow, sumCol) { //construct a summary row var isNum = !isNaN(obj[0][sumCol]) //only sum numeric fields return (sumRow[sumCol] ...
-
以下是ClojureScript的等价物: (defn key-value [obj] (loop [acc [] ks (.keys js/Object obj)] (if (seq ks) (recur (conj acc (clj->js {(first ks) (aget obj (first ks))})) (rest ks)) (clj->js acc)))) 或者使用reduce而不是loop / recur: (defn key-value [obj] ...
-
这是我需要的正确答案。 很抱歉最近发布它并感谢您的所有努力。 谢谢。 data.children = []; var childArr = [ 'ft Some older versions read, ', 'fqa And we are writing these things to you so that your joy will be complete. ', 'fqb ', 'f*' ]; var data = {}; data.childr ...
-
如果要为每个数组定义一个单独的数组,则可以使用switch语句。 var roster = [ {player: "Ben", position: "qb", salary: 1000}, {player: "Brown", position: "wr", salary: 1200}, {player: "Landry", position: "qb", salary: 800} ]; var qbArray = []; var wrArray = []; function parseIn ...
-
您可以使用JSON.stringify()方法将对象转换为JSON字符串。 console.log(JSON.stringify(myList)); 更新:您的问题输出不是有效的json,要转换为该格式使用String#replace方法。 console.log(JSON.stringify(myList).replace(/({\s?|,\s?)"(\w+)":/g,'$1$2:')); You can use JSON.stringify() method to convert the objec ...