我一直在努力掌握这个概念,即使经过多次实验,我仍然无法弄清楚WPF中的ObservableCollections和使用BindingOperations.EnableCollectionSynchronization的最佳实践.
如果我有一个带有可观察集合的viewmodel,我使用锁启用集合同步,如下所示:
m_obsverableCollection = new ObservableCollection<..>;
BindingOperations.EnableCollectionSynchronization(m_obsverableCollection,
m_obsverableCollectionLock);
Run Code Online (Sandbox Code Playgroud)
这是否意味着对该可观察集合的每次修改和枚举都将:
使用BindingOperations.EnableCollectionSynchronization时,我是否需要显式执行任何类型的锁定?
产生这一切的问题是,即使在使用BindingOperations.EnableCollectionSynchronization并使用我传入该方法的相同锁定锁定项目后,我偶尔会得到"这种类型的CollectionView不支持从不同于该线程的线程更改其SourceCollection调度员线程." 例外
我尝试创建特定类的类型,但我不能将它们作为通用表示返回,有人可以告诉我如何实现它吗?对于反对/协方差魔法,我有点轻松
public DashboardNotification<IDashboardEntry> Get()
{
//return new MyNotWorkingNotification(); // doesn't compile, I want to achieve this
return new MyWorkingNotification(); // compiles
}
public class DashboardNotification<T> where T : IDashboardEntry
{
}
public interface IDashboardEntry
{
}
public class MyNotWorkingNotification : DashboardNotification<MyDashboardEntry>
{
}
public class MyWorkingNotification : DashboardNotification<IDashboardEntry>
{
}
public class MyDashboardEntry : IDashboardEntry
{
}
Run Code Online (Sandbox Code Playgroud) 我有用于API身份验证的IdentityServer4设置,尽管我有一个用例,我想验证guest(用户)本质上是一个有效的用户.在我的情况下,有效用户是拥有有效电子邮件地址的任何人,因此我想执行以下操作:
我想知道是否可以/应该使用IdentityServer4来实现上述目标?
他们的工具显示你可以生成一个令牌,虽然我对这个主题很新,所以希望得到一些指导.