我正在开发winforms应用程序.我想在ListView上应用过滤器.当在文件夹中搜索具有给定名称的文件时,要求是在窗口中实现精确搜索功能.
事实证明,Windows正在使用相关值来订购找到的文件.
我在想,也许winforms在一个Control或另一个Control中实现了这个算法?或者也许.NET有一些在哪里?如果没有,是否有这个算法的C#代码,我可以使用它来手动订购过滤的对象:
var searchFor = "search";
var newList = oldList.Select(x =>x.Contains(searchFor))
.OrderBy(x => RelevanceValues(x,searchFor))
.ToList();
Run Code Online (Sandbox Code Playgroud) 我在Visual Studio 2015中创建了一个使用TypeScript 1.8创建的项目.安装Visual Studio 2017后,我尝试在新IDE中打开旧项目.如果我检查项目的属性,我得到这个:
TypeScript版本:1.8(不可用).
但是,我可以看到这个版本已经存在C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8
.
我不想使用更新的版本,因为我现在不想更改代码.
Visual Studio 2017是否支持TypeScript 1.8?
如何将此版本提供给VS 2017?
在生产中安装我的Windows服务之前,我一直在寻找可以执行的可靠测试,以确保我的代码不包含内存泄漏.但是,我在网上找到的所有内容都是使用任务管理器查看已用内存或某些付费内存分析器工具.
根据我的理解,查看任务管理器并不是真正有用,也无法确认内存泄漏(如果有的话).
如何确认是否有内存泄漏?
有没有免费的工具来查找内存泄漏的来源?
注意:我正在使用.Net Framework 4.6和Visual Studio 2015社区
我有一个类Product
来保存给定产品的特定实例.此类包含与主要产品类似的相关产品列表.
class Product
{
public string Name;
public double Rating;
public List<Product> RelatedProducts;
//...
public List<Product> GetTopRelatedProducts(int N)
{
// How to implement this method
// What I did so far(Bad code)
// 1- INFINITE RECURSION
// 2- Can not remember visited objects
var myList = new List<Product>();
foreach(Product prod in RelatedProducts)
{
myList.AddRange(prod.GetTopRelatedProducts(N));
}
return myList.Distinct().OrderByDescending(x => x.Rating).Take(N).ToList();
}
}
Run Code Online (Sandbox Code Playgroud)
我想在Product
课堂上定义一种方法来获得最佳N
(评价最高)的相关产品.此方法应考虑RelatedProducts
列表中的元素是类型,Product
并且它们也有自己的RelatedProducts
列表.因此,我应该继续导航嵌套对象,直到达到所有相关产品,然后取出前N个产品.我的意思是,解决方案不会简单this.RelatedProducts.OrderByDescending(x => x.Rating).Take(N);
还有一点要记住:两种产品可以相互关联.这意味着一个产品 …
在Outlook Web Add-In中,我试图拦截OnSend
在发送电子邮件时触发的事件.
我在GitHub中使用了这个例子,它运行正常.
如果我在电子邮件正文中包含"附件"一词,并单击"发送"按钮,OnSend
则会触发一次事件,并弹出一个弹出模式窗口,显示以下消息:
附件提醒
您可能忘记附加文件.
使用发送和不发送按钮.如果单击" 发送",OnSend
事件将被触发两次:Send
在附件提醒中单击按钮后2次.我只期待像第一个发送一样的事件.
如何OnSend
在附件提醒后进行事件触发?
我有一个父组件,它是一个表单,它通过redux连接到商店:
// FormComponent
export default connect(mapStateToProps, mapDispatchToProps)(FormComponent);
Run Code Online (Sandbox Code Playgroud)
在该表单中,我有一个输入属性列表,它是表单的子组件:
我需要通过在输入失去焦点时传递包含所有属性的JSON对象来进行更新API调用,从而将任何字段中的更改保存到服务器.
API调用将是这样的:
updatePersonInfo({firstname: 'new name', lastname: 'new name', address: 'new address' });
Run Code Online (Sandbox Code Playgroud)
我的想法是将PersonInfo
对象作为道具从Form组件传递给所有子组件.每个子组件将从PersonInfo
props 更新一个属性,并使用更新的PersonInfo
对象调度UPDATE_PERSONINFO操作.但要做到这一点,我还需要将所有子组件连接到存储:
// FirstNameComponent
export default connect(mapStateToProps, mapDispatchToProps(FirstNameComponent);
// LastNameComponent
export default connect(mapStateToProps, mapDispatchToProps)(LastNameComponent);
// AddressComponent
export default connect(mapStateToProps, mapDispatchToProps)(AddressComponent);
Run Code Online (Sandbox Code Playgroud)
但我认为我们应该避免因为性能原因而使用connect.另外,我不相信我需要4个连接器来调用一个动作.
什么是处理这种情况的最佳选择?
我正在使用Qunit
框架来测试前端Web应用程序.我需要为代码覆盖生成报告.为此,我试图istanbul
通过gulp任务使用.我gulpfile.js
看起来像:
var gulp = require('gulp'),
qunit = require('gulp-qunit'),
istanbul = require('gulp-istanbul');
gulp.task('test1', function() {
return gulp.src('test/test.html')
.pipe(qunit());
});
gulp.task('test2', function () {
return gulp.src('lib/*.js')
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test3', ['test2'], function () {
return gulp.src('test/test.html')
.pipe(qunit())
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 90%
.pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
Run Code Online (Sandbox Code Playgroud)
运行test3
将成功完成但代码覆盖率不会.
输出test3 …
我看到了很多关于ReSharper的好评.所以我试一试,我真的很喜欢它.我甚至建议我的团队使用它并在这个工具上投入一些钱.但他们感到悲伤" 因为我们使用的是Visual Studio 2010,因此我们更好地将资金用于更新Visual Studio,因为新版本具有几乎所有ReSharper功能 ".
ReSharper在Visual Studio 2015或2017中无用吗?
当我注意到这一点时,我正在对可空类型进行一些比较:
int? a = null;
int? b = null;
// a == b; ==> true
// a <= b; ==> false
Run Code Online (Sandbox Code Playgroud)
对我来说,<=
运营商就相当于== OR <
既然a == b
是true
的,我也除外true
了a <= b
.
对你来说似乎也不合逻辑吗?
为什么<=
和>=
运营商这样做?有什么特别的原因吗?
我有资源Student
和 4 个 API 端点:
POST: /students
GET: /students/{id}
PUT: /students/{id}
DELETE: /students/{id}
Run Code Online (Sandbox Code Playgroud)
现在,我想将新属性Address
作为对象添加到Student
:
class Student
{
public int Id;
public string Name;
public Address Address;
}
Run Code Online (Sandbox Code Playgroud)
Address
Street
也有作为对象的属性。
我的问题是,如果我只想更新address
或street
,最好是:
PUT: /students/{id}/address
并PUT: /students/{id}/address/street
c# ×4
algorithm ×1
api ×1
gulp ×1
istanbul ×1
java ×1
javascript ×1
memory-leaks ×1
office-js ×1
qunit ×1
react-redux ×1
reactjs ×1
recursion ×1
resharper ×1
rest ×1
typescript ×1
winforms ×1