0

我的测试代码片段:
using (ShimsContext.Create()) {
taskService = new ShimTaskService { TargetServerGet = () => "192.168.100.1", UserNameGet = () => "user", UserAccountDomainGet = () => "TestDomain" , UserPasswordGet = () => "p/w", RootFolderGet = () => new ShimTaskFolder { TasksGet = () => new List { new ShimTask {NameGet = () => taskName }}; 我有错误:

        > Cannot convert lambda expression to type system.collections.generic.List< Microsoft.Win32.TaskScheduler.Task>
        > to return type system.collections.generic.List<
        > Microsoft.Win32.TaskScheduler.TaskCollection>. How convert this
        > collection?    

                // TaskGet: 
                public FakesDelegates.Func<TaskCollection> TasksGet { set; }

                // TaskCollection:
                public sealed class TaskCollection : IEnumerable<Task>, IEnumerable, IDisposable
            {
                public int Count { get; }

                public Task this[int index] { get; }
                public Task this[string name] { get; }

                public void Dispose();
                public IEnumerator<Task> GetEnumerator();
            }
4

1 回答 1

0

假设这是来自 codeplex 的 TaskCollection,那么您不能创建自己的TaskCollection来包装任意Task. 这不是预期的用途。您将需要更改您的设计,或更改托管包装器的源代码并重建库。

于 2013-06-18T08:05:28.477 回答