问题:
ItemsControl(或从中派生的控件ItemsControl).ItemsControl.ItemsSource属性绑定到ObservableCollectionViewModel中的a.ObservableCollection.ObservableCollection.背景:
这似乎是许多WPF开发人员遇到的常见问题.有人问过几次:
ObservableCollection没有注意到它中的Item何时发生变化(即使使用INotifyPropertyChanged)
ObservableCollection和Item PropertyChanged
我的实施:
当Item更改时,我尝试在Notify ObservableCollection中实现接受的解决方案.基本思想是PropertyChanged在MainWindowViewModel中为每个项目连接一个处理程序ObservableCollection.更改项目的属性时,将调用事件处理程序,并以某种方式更新视图.
我无法让实现工作.这是我的实施.
的ViewModels:
class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName = "")
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
Run Code Online (Sandbox Code Playgroud)
项目视图模型:
class EmployeeViewModel : ViewModelBase
{
private int _age;
private string _name;
public int Age
{ …Run Code Online (Sandbox Code Playgroud) 编译以下代码时,Visual Studio报告:
\main.cpp(21): error C2664: 'std::_Call_wrapper<std::_Callable_pmd<int ClassA::* const ,_Arg0,false>,false> std::mem_fn<void,ClassA>(int ClassA::* const )' : cannot convert argument 1 from 'overloaded-function' to 'int ClassA::* const '
1> with
1> [
1> _Arg0=ClassA
1> ]
1> Context does not allow for disambiguation of overloaded function
Run Code Online (Sandbox Code Playgroud)
编译时为什么编译器会混淆mem_fptr1?但是mem_fptr2当我指定类型时,有些可以.
我可以创建成员函数指针指向不带参数的重载成员函数吗?
class ClassA
{
public:
void memberfunction()
{
std::cout <<"Invoking ClassA::memberfunction without argument" << std::endl;
}
void memberfunction(int arg)
{
std::cout << "Invoking ClassA::memberfunction with integer " << arg << std::endl;
} …Run Code Online (Sandbox Code Playgroud) 我正在学习Angular 2和Azure.我遵循了Angular 2 Tutorial,一切都在本地运行良好.
我将应用程序发布到Azure.该出版物成功了.但是当我访问该网站时,它仍处于加载阶段.查看Chrome控制台中的日志,我看到以下错误./app/main.ts找不到该文件.
我按照此问题的建议通过"Kudu"仪表板检查了我部署的文件.我没有看到任何*.ts只部署*.js和*.map.
然后我回到Visual Studio将所有*.ts文件的属性更改为Copy Always.更改后,我可以看到*.ts文件被复制到.\bin\app目录中.但是,在我将项目重新发布到Azure(再次成功)后,我仍然在请求main.ts文件时遇到404错误.
根据这个问题, IIS无法正确提供Typescript文件.
首先:如何在Azure上应用建议的更改来修复它?
其次:为什么我们需要使用这些*.ts文件?根据我的理解,*.ts遵守*.js.为什么我们不能只请求*.js正确部署到Azure 的文件?
我为异步类成员编写了一个单元测试.当我在"Debug build"下执行测试时,测试按预期传递.但是,当我在"Release build"下执行我的测试时,它会挂起CPU(当循环死锁时).
如果我使用Debug构建(即Debug构建单元测试程序集和Release构建目标程序集)专门配置Unit测试项目,那么测试也会通过.
要测试的代码
public override void DoSomething(object parameter)
{
ThreadPool.QueueUserWorkItem(AsyncDoSomething, parameter);
}
private void AsyncDoSomething(object parameter)
{
//Doing something
.....
//Something is done
RaiseSomethingIsDone();
}
Run Code Online (Sandbox Code Playgroud)
我的单元测试
public void DoingSomethingTest()
{
bool IsSomethingDone = false;
//Setup
//Doing some setup here.
target.SomethingDone += (sender, args) =>
{
IsSomethingDone = true;
};
//Exercise
target.DoSomething(_someParameter);
while (!IsSomethingDone ){}
//Verify
//Doing some asserts here.
}
Run Code Online (Sandbox Code Playgroud)
这是在调试配置和发布配置下由C#编译器生成的IL:
调试while循环IL interpenetration:
IL_00cb: ldloc.s 'CS$<>8__locals7'
IL_00cd: ldfld bool IsSomethingDone
IL_00d2: ldc.i4.0
IL_00d3: ceq
IL_00d5: stloc.s CS$4$0001
IL_00d7: …Run Code Online (Sandbox Code Playgroud) 我是Azure和Angular2的新手.
目标
使用GitHub设置Azure持续部署.
问题
Azure正在获取存储库主分支的提交.所以这部分还可以.但是,由于生成错误,部署失败.
这是部署详细信息:
这是完整的日志:
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
All packages listed in packages.config are already installed.
D:\home\site\repository\LearnJS\LearnJS.Web\app\app.component.ts(1,41): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj]
D:\home\site\repository\LearnJS\LearnJS.Web\app\app.component.ts(2,46): error TS2307: Build: Cannot find module 'angular2/router'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj]
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis-form.component.ts(1,25): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj]
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis-form.component.ts(2,22): error TS2307: Build: Cannot find module 'angular2/common'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj]
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.component.ts(1,33): error TS2307: Build: Cannot find module 'angular2/core'. [D:\home\site\repository\LearnJS\LearnJS.Web\LearnJS.Web.csproj]
D:\home\site\repository\LearnJS\LearnJS.Web\app\crisis.component.ts(2,30): error TS2307: …Run Code Online (Sandbox Code Playgroud) 我的配置如下:
OS:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.4 LTS"
NAME="Ubuntu"
VERSION="14.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.4 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
Run Code Online (Sandbox Code Playgroud)
Visual Studio代码
1.5.3
Xming的 6.9.0.31
为了安装visual studio代码,我不得不跳了很多箍.最后,我设法做到了.我跑的时候
code 要么 code .
它立即返回到命令行,没有错误.
然后我跑了
code --verbose
Run Code Online (Sandbox Code Playgroud)
我收到以下消息.
OpenGL Warning:
XComposite not found or old version (0.0), no VisibilityTracking
{ [Error: ENOENT: no such file or directory, open '/home/vagrant/.config/Code/storage.json']
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/home/vagrant/.config/Code/storage.json' }
(5:08:07 AM) ### VSCode main.js ###
(5:08:07 AM) /usr/share/code/resources/app { …Run Code Online (Sandbox Code Playgroud) 我使用的是EF 6.0和SQL Server CE 4.0.该.sdf文件受密码保护,我通过LinqPad打开文件验证了该文件.当我尝试使用以下连接字符串在代码中打开此数据库时,我得到一个异常:
指定的密码与数据库密码不匹配
码:
using (var context = new MyDbContext("ExamManagement"))
{
context.Database.Initialize(false);
}
Run Code Online (Sandbox Code Playgroud)
连接字符串:
<connectionStrings>
<add name="ExamManagement"
connectionString="Data Source=|DataDirectory|Pikeman.sdf;Max Database Size=4091;Password=123;"
providerName="System.Data.SqlServerCe.4.0" />
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
位于System.Data.Entity.Core.EntityClient.EntityConnection.Open()
处于System.Data.Entity.Core.Object.Entity上的System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
中的System.Data.Entity. ](Func键1.<> c__DisplayClass7.b__5() 在System.Data.Entity.Core.Objects.ObjectQuery 1 forMergeOption) 在System.Data.Entity.Core.Objects.ObjectQuery 1.MoveNext() 在System.Linq.Enumerable .First [TSource](IEnumerable`1 source)1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Data.Entity.Internal.LazyEnumerator
我一直在关注Angular 2开发指南.我在做9路由和导航里程碑3时遇到了这个问题
我添加了一个getCrisis带一个参数的函数sn.该函数Promise<Crisis>异步返回.
crisis.service.ts
import {Injectable} from 'angular2/core';
import {CRISES} from './mock-crisises';
@Injectable()
export class CrisisService {
getCrisises() {
return Promise.resolve(CRISES);
}
// the | string token is a Pipe
getCrisis(sn: number | string) {
return Promise.resolve(CRISES).then(cries => cries.filter(c => c.serialNumber === +sn)[0]);
}
}
Run Code Online (Sandbox Code Playgroud)
危机form.component.ts调用getCrisis上ngOnInit
export class CrisisFormComponent implements OnInit, CanDeactivate{
public model: Crisis;
public origin: Crisis;
submitted = false;
active = true;
constructor(
private _service: CrisisService, …Run Code Online (Sandbox Code Playgroud) 在四核CPU上运行以下代码时,我保证这四个线程将在四个不同的内核上运行吗?
或者操作系统可以根据系统的工作负载在单个核心上放置多个线程.如果是这种情况,由于上下文切换和其他线程开销,运行多线程甚至可能会给您带来性能损失.
我想没有办法对应用程序进行编码,这会强制线程在不同的内核上运行?
int main()
{
std::vector<std::thread> threads(3);
for (size_t i = 0; i < 3; i++)
{
threads[i] = std::thread(DoSomethingLengthy);
}
DoSomethingLengthy();
for (auto& thread : threads)
{
thread.join();
}
}
Run Code Online (Sandbox Code Playgroud) angular ×3
azure ×2
c# ×2
c++ ×2
c++11 ×1
github ×1
itemscontrol ×1
linux ×1
mvvm ×1
node.js ×1
typescript ×1
unit-testing ×1
wpf ×1