1

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

这发生在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'  

编辑

我被要求提供一些代码。我仍在努力,但我试图让它运行。我基本上试图让分页机制和 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 调用中获得的内容推送到列表中的最佳方法是什么。

4

0 回答 0