小编ras*_*asx的帖子

如何确定ASP.NET MVC的当前版本?

有没有办法在代码中获取当前版本的ASP.NET MVC?需要反思MVC程序集吗?任何新的IIS服务器变量?在HTTP上下文中读取一些属性?

asp.net-mvc

82
推荐指数
4
解决办法
6万
查看次数

IObservable <T> .ToTask <T>方法返回等待激活的任务

为什么要task永远等待?:

var task = Observable
    .FromEventPattern<MessageResponseEventArgs>(communicator, "PushMessageRecieved")
    .Where(i => i.EventArgs.GetRequestFromReceivedMessage().Name == requestName)
    .Select(i => i.EventArgs)
    .RunAsync(System.Threading.CancellationToken.None)
    .ToTask();

task.Wait();
Run Code Online (Sandbox Code Playgroud)

我知道"PushMessageRecieved"被解雇了; 我可以在Select lambda上设置一个断点并点击它.但task.Wait()永远不会动.

更好的更新: FirstAsync()我正在寻找:

    public static Task<MessageResponseEventArgs> HandlePushMessageRecievedAsync(this ICommunicator communicator, RequestName requestName)
    {
        if (communicator == null) return Task.FromResult<MessageResponseEventArgs>(null);

        var observable = GetCommunicatorObservableForPushMessageReceived(communicator);
        return observable
            .Where(i => i.GetRequestFromReceivedMessage().Name == requestName)
            .Select(i => i)
            .FirstAsync()
            .ToTask();
    }
Run Code Online (Sandbox Code Playgroud)

在哪里GetCommunicatorObservableForPushMessageReceived():

    static IObservable<MessageResponseEventArgs> GetCommunicatorObservableForPushMessageReceived(ICommunicator communicator)
    {
        if (communicatorObservableForPushMessageReceived == null)
        {
            communicatorObservableForPushMessageReceived = Observable
                .FromEventPattern<MessageResponseEventArgs>(communicator, "PushMessageRecieved") …
Run Code Online (Sandbox Code Playgroud)

c# task-parallel-library system.reactive

7
推荐指数
1
解决办法
3566
查看次数

为什么没有Microsoft.Win64命名空间?

我们有一个Microsoft.Win32命名空间,但它是否可以在64位Windows环境中工作?是否有同等的需要为64位情况定义这样的定义?

.net windows

6
推荐指数
1
解决办法
2149
查看次数

使用VSTS的WPF警告:为'*.g.cs'文件指定了不同的校验和值

在Visual Studio 2008 Team System中,这是我的警告:

Different checksum values given for '<some folder>' ...\Visual Studio 2008\Projects\...
\Debug\...\SomeFile.g.cs
Run Code Online (Sandbox Code Playgroud)

SomeFile.g.cs文件中的违规行是:

#pragma checksum "..\..\..\..\..\..\...\SomeFile.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "A18BC47B27EC4695C69B69F1831E3225"
Run Code Online (Sandbox Code Playgroud)

我删除了所有的的*.g.cs文件,在解决方案和重建,所有的警告回来了.这到底是什么?

wpf xaml visual-studio-2008

6
推荐指数
1
解决办法
2025
查看次数

jQuery:扩展,添加新功能和构建插件?

今天,关于jQuery的唯一紧迫问题是关于何时使用jQuery.extend()jQuery.fn(用于插件).Basil Goldman似乎在" 在jQuery中定义你自己的函数 "中有一个解释,但由于某种原因,我仍然不满意我有最好的信息.一旦我们开始合作,jQuery.fn我们必须考虑是否应该构建一个完整的插件.这意味着三个问题:扩展,添加新功能和构建插件.应该有一个解释,这三个都是一致的.这值得解释,我们有吗?

jquery

5
推荐指数
1
解决办法
6183
查看次数

布尔“match”表达式有简写吗?

match这里的表达式有简写吗isVertical

let bulmaContentParentTile isVertical nodes =
    let cssClasses =
        let cssDefault = [ "tile"; "is-parent" ]
        match isVertical with
        | true -> cssDefault @ [ "is-vertical" ]
        | _ -> cssDefault

    div [ attr.classes cssClasses ] nodes

Run Code Online (Sandbox Code Playgroud)

我认为像这样的表达方式match isVertical with是如此常见,以至于有一个类似于我们的 for 的简写function,不是吗?

f# pattern-matching

5
推荐指数
2
解决办法
216
查看次数

这篇MSDN文章是否违反了MVVM?

这可能是旧闻,但早在2009年3月,本文" Silverlight 2 Apps中的Model-View-ViewModel "就有了一个代码示例,其中包括DataServiceEntityBase:

// COPIED FROM SILVERLIGHTCONTRIB Project for simplicity

/// <summary>
/// Base class for DataService Data Contract classes to implement 
/// base functionality that is needed like INotifyPropertyChanged.  
/// Add the base class in the partial class to add the implementation.
/// </summary>
public abstract class DataServiceEntityBase : INotifyPropertyChanged
{
/// <summary>
/// The handler for the registrants of the interface's event 
/// </summary>
PropertyChangedEventHandler _propertyChangedHandler;

/// <summary>
/// Allow inheritors to fire the …
Run Code Online (Sandbox Code Playgroud)

silverlight wcf entity-framework mvvm

4
推荐指数
1
解决办法
342
查看次数

Silverlight没有Math.Truncate!......这个等同的工作吗?

Math.Truncate在大多数情况下,这是否相同:

double x = 1034.45
var truncated = x - Math.Floor(Math.Abs(x));
Run Code Online (Sandbox Code Playgroud)

哪里truncated == 0.45

更新中...

感谢输入人!这对我有用:

[TestMethod]
public void ShouldTruncateNumber()
{
    double x = -1034.068;
    double truncated = ((x < 0) ? -1 : 1) * Math.Floor(Math.Abs(x));

    Assert.AreEqual(Math.Truncate(x), truncated, "The expected truncated number is not here");
}
Run Code Online (Sandbox Code Playgroud)

这个也是:

[TestMethod]
public void ShouldGetMantissa()
{
    double x = -1034.068;
    double mantissaValue = ((x < 0) ? -1 : 1) *
        (Math.Abs(x) - Math.Floor(Math.Abs(x)));
    mantissaValue = Math.Round(mantissaValue, 2);

    Assert.AreEqual(-0.07, mantissaValue, …
Run Code Online (Sandbox Code Playgroud)

math silverlight

3
推荐指数
1
解决办法
1241
查看次数

用lock包装一个Task不是很有用吗?

这里有什么意图?:

lock(Locker)
{
    Task.Factory.StartNew(()=>
    {
        foreach(var item in this.MyNonCurrentCollection)
        {
          //modify non-concurrent collection
        }
    }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchonizationContext())
    .ContinueWith(t => this.RaisePropertyChanged("MyNonCurrentCollection"));
}
Run Code Online (Sandbox Code Playgroud)

系统lock(队列)Task是否会完成或者系统只会锁定以启动新的Task?后者意味着如果无用,这种锁是好的,对吧?我只是想从别人的代码中发现意图.这里的理想是防止MyNonCurrentCollection被另一个线程修改.

c# multithreading task-parallel-library

3
推荐指数
1
解决办法
892
查看次数

Autofac WithKey属性未按预期工作(多个实现)

我试图在LinqPad中重建问题:

/*
    “Named and Keyed Services”
    http://autofac.readthedocs.org/en/latest/advanced/keyed-services.html
*/

const string A = "a";
const string B = "b";
const string MyApp = "MyApp";

void Main()
{
    var builder = new ContainerBuilder();
    builder
        .RegisterType<MyClassA>()
        .As<IMyInterface>()
        .InstancePerLifetimeScope()
        .Keyed<IMyInterface>(A);
    builder
        .RegisterType<MyClassB>()
        .As<IMyInterface>()
        .InstancePerLifetimeScope()
        .Keyed<IMyInterface>(B);
    builder
        .RegisterType<MyAppDomain>()
        .Named<MyAppDomain>(MyApp);

    var container = builder.Build();

    var instance = container.ResolveKeyed<IMyInterface>(A);
    instance.AddTheNumbers().Dump();

    var myApp = container.ResolveNamed<MyAppDomain>(MyApp);
    myApp.Dump();
}

interface IMyInterface
{
    int AddTheNumbers();
}

class MyClassA : IMyInterface
{
    public int AddTheNumbers() { return 1 + 2; }
} …
Run Code Online (Sandbox Code Playgroud)

autofac linqpad

3
推荐指数
1
解决办法
367
查看次数