我在这篇文章中读过:" Rx的喜悦:基于事件的异步模式与IObservable ",使用EBAP是不鼓励的.使用新的Rx扩展设计异步组件的最佳方法是什么(类似于msdn的PrimeNumberCalculator示例)?
先感谢您.
更新 我设法写了自己的素数计算器,我想听听你的意见:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace ConsoleApplication13
{
public class PrimeNumberCalculator
{
private readonly Subject<int> primeSubject;
private IDisposable currentSubscription;
public PrimeNumberCalculator()
{
primeSubject = new Subject<int>();
Primes = primeSubject.Hide();
}
public IObservable<int> Primes{ get; private set; }
/// <summary>
/// Determine if n is prime.
/// </summary>
private static bool IsPrime(ArrayList primes, int n, out int firstDivisor)
{
bool foundDivisor = false;
bool exceedsSquareRoot = false;
int i = …Run Code Online (Sandbox Code Playgroud) 我有类型的记录
type tradeLeg = {
id : int ;
tradeId : int ;
legActivity : LegActivityType ;
actedOn : DateTime ;
estimates : legComponents ;
entryType : ShareOrDollarBased ;
confirmedPrice: DollarsPerShare option;
actuals : legComponents option ;
type trade = {
id : int ;
securityId : int ;
ricCode : string ;
tradeActivity : TradeType ;
enteredOn : DateTime ;
closedOn : DateTime ;
tradeLegs : tradeLeg list ;
}
Run Code Online (Sandbox Code Playgroud)
贸易腿显然是一种交易类型.一条腿可能已经结算或未结算(或未结算但已确认价格) - 因此我已定义了活动模式:
let (|LegIsSettled|LegIsConfirmed|LegIsUnsettled|) (l: tradeLeg) =
if …Run Code Online (Sandbox Code Playgroud) 在Botan v1.8.8上运行gcc v3.4.6在成功构建Botan并运行自检后,我得到以下编译时错误构建我的应用程序:
../../src/Botan-1.8.8/build/include/botan/secmem.h: In member function `Botan::MemoryVector<T>& Botan::MemoryVector<T>::operator=(const Botan::MemoryRegion<T>&)':
../../src/Botan-1.8.8/build/include/botan/secmem.h:310: error: missing template arguments before '(' token
Run Code Online (Sandbox Code Playgroud)
这个编译器错误告诉我什么?这是secmem.h的一个片段,包括第310行:
[...]
/**
* This class represents variable length buffers that do not
* make use of memory locking.
*/
template<typename T>
class MemoryVector : public MemoryRegion<T>
{
public:
/**
* Copy the contents of another buffer into this buffer.
* @param in the buffer to copy the contents from
* @return a reference to *this
*/
MemoryVector<T>& operator=(const MemoryRegion<T>& in)
{ …Run Code Online (Sandbox Code Playgroud) var details= from row in databaseTable
where row.id equals queryId
select new
{
Dict = row.ToDictionary(x => x.Name, x => x.Value),
};
Run Code Online (Sandbox Code Playgroud)
执行此LINQ to SQL时,我得到错误;
System.NotSupportedException:不支持查询运算符"ToDictionary".
我需要做的是先将行拉入内存,但我不确定如何.我尝试在各个地方调用ToList,但没有运气.
我有一个实体类.这个实体有很多属性和实体的数据显示给用户一些TabItems的TabControl.我还实现了MVVM方法.
当屏幕首先显示给用户时,我想只绑定活动标签页控件,当用户浏览标签页时,将根据需要产生额外的单独绑定.我怎样才能做到这一点?
我在它自己的进程中使用NServiceBus(因此不使用通用主机),我希望按特定顺序为消息提供多个消息处理程序.对于通用主机,您将实现ISpecifyMessageHandlerOrdering,但我不知道如何在托管您自己的NServiceBus进程时执行此操作,因为该接口已定义,NServiceBus.Host.exe并且我无法找到另一种方法来执行此操作.
这样做的目的是用户身份验证:在调用实际的消息处理程序之前,我首先要对消息的发送者进行身份验证,这将发生在不同的,更通用的消息处理程序中.该消息的类型包含加密的用户名和密码和/或会话ID.此类型将用于发送到服务器的几乎所有命令(我认为除了登录之外的所有命令).这是使用NServiceBus进行用户身份验证的好方法吗?
目前,它会选择第二个处理程序但不是正确的顺序.
更新
正如大卫所建议的那样,我尝试创建一个IMessageModule并从中读取标题CurrentMessageContext以对用户进行身份验证.
我遇到了一些问题:
bus.CurrentMessageContext是null.每次之后,它都被正确填写,我可以阅读标题.bus.DoNotContinueDispatchingCurrentMessageToHandlers在未对用户进行身份验证时调用不会阻止调用消息处理程序.也没有bus.Return(errorCode).还有其他方法吗?有没有人弄清楚为什么.net 4.0的sn.exe崩溃如果在外面运行崩溃C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\
?(使用Windows XP,32位)
Visual Studio 2010工作得很好,sn工作在NETFX 4.0工具中(直接调用或在PATH上调用).
.net 3.5版本(来自..\Bin)工作正常,可以移动.
我只是试图获得一个自动构建,但似乎sn.exe需要住在它的位置......这可能是什么?我错过了一些明显的东西吗
这是我第一次尝试使用DI,我选择了ninject因为它据说很容易学习,并且有这个问题.
我正在创建这样的对象:
var registrants = JsonConvert.DeserializeObject<List<Registrant>>(input);
Run Code Online (Sandbox Code Playgroud)
我目前有这个构造函数 Registrant
[Inject]
public Registrant(IMemberRepository memberRepository)
{
_memberRepository = memberRepository;
}
Run Code Online (Sandbox Code Playgroud)
使用Ninject将存储库依赖项注入反序列化对象的最佳方法是什么?
对于我们的.Net应用程序,我们已将许可组件集成到应用程序中 在应用程序代码中,我们验证许可证,并在此基础上我们需要启用/禁用某些功能.例如,如果用户具有试用许可证,则他们只能访问应用程序的特定部分,而付费用户可以访问任何部分.我需要帮助决定设计,以便影响最小.我不想在if..else语句中撒上代码.请与我分享一些实现这一目标的最佳方法.
我的ASP.NET MVC 3应用程序使用Ninject和Ninject ASP.NET MVC 3集成.我重载了CreateKernel方法.
现在我需要以这种方式为每个查询设置一些依赖项:
if (Language == Language.English)
//register English language implementations
else if (Language == Language.Russian)
//register Russain language implementations
Run Code Online (Sandbox Code Playgroud)
我thougt一些Global_asax的请求特定的方法将是一个不错的地方,并试图访问某些NinjectHttpApplicaton性质的登记每个请求的依赖关系.我访问了内核并得到了过时的警告"不要使用Ninject作为服务定位器".我究竟做错了什么?怎么做对了?
.net ×3
c# ×3
ninject ×2
.net-4.0 ×1
asp.net ×1
asp.net-mvc ×1
asynchronous ×1
binding ×1
botan ×1
c++ ×1
f# ×1
iasyncresult ×1
lazy-loading ×1
linq-to-sql ×1
list ×1
messaging ×1
mvvm ×1
nservicebus ×1
sn.exe ×1
tabcontrol ×1
templates ×1
wpf ×1