Caliburn.Micro:无法找到源文件SequentialResult.cs

时间:2012-06-25 17:24:37

标签: wpf caliburn.micro coroutine

尝试在Caliburn.Micro中使用IResult Coroutines抛出这个奇怪的异常,我做错了什么还是框架坏了?

这发生在yield return resultresult是自定义IResult类。

Locating source for 'C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs'. Checksum: MD5 {a2 6e ce dd c5 8c b3 ec 9c 21 b7 9 29 24 e7 a5}
The file 'C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs' does not exist.
Looking in script documents for 'C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs'...
Looking in the projects for 'C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs.
The debugger could not locate the source file 'C:\Projects\Blue Spire\Caliburn.Micro\src\Caliburn.Micro.Silverlight\SequentialResult.cs'  

修改

我被要求提供一些代码。我还在努力,但我试图让它运行。我基本上试图让Paging机制和CM IResult一起工作来调用WCF服务。

public class PagedRequestManager<T>: IResult where T : IPagedRequest
{
    public delegate IAsyncResult BeginRequestDelegate<T>(T request, AsyncCallback callback, object state);
    public delegate IPagedResponse EndRequestDelegate(IAsyncResult result);

    private BeginRequestDelegate<T> _beginRequest;
    private EndRequestDelegate _endRequest;
    private T _request;

    public IPagedResponse Response { get; private set; }

    public PagedRequestManager(BeginRequestDelegate<T> beginRequest, EndRequestDelegate endRequest, T request)
    {
        _beginRequest = beginRequest;
        _endRequest = endRequest;
        _request = request;
    }

    public event EventHandler<ResultCompletionEventArgs> Completed;

    public void Execute(ActionExecutionContext context)
    {
        _beginRequest(_request, PagedCallback, null);
    }

    private void PagedCallback(IAsyncResult result)
    {
        Response = _endRequest(result);
        OnCompleted();
    }

    private void OnCompleted()
    {
        var handler = Completed;
        if (handler != null)
        {
            handler(this, new ResultCompletionEventArgs());
        }
    }
}


public interface IPagedRequest
{
    PageContext PageInfo { get; set; }
}


public interface IPagedResponse
{
    PageContext PageInfo { get; }
    IEnumerable Result { get; }
}

和用法:

public IEnumerable<IResult> TestWCF()
{
    var result = new PagedRequestManager<GetItemsRequest>(client.BeginGetItems, client.EndGetItems, new GetItemsRequest() { PageInfo = new PageContext() { Skip = 0, Take = 10 } });
    yield return result;
}

虽然我们可能会有人想提一下这是否是一个很好的解决方案。我不确定如何使用CM的IResult机制以及将每个WCF调用中的内容推送到列表中的最佳方法。

0 个答案:

没有答案