ViewDataFactory and strongly typed master pages

余生长醉 提交于 2019-12-03 21:41:26

Why don't you just add a semicolon at the end of that line? :)

Abstract methods (as well as interface methods) have a semicolon in place of a body.

Martin

I finally got it working thanks to Aviad P.'s suggestions and some trial and error.

This is how my IViewDataFactory ended up looking like:

public interface IViewDataFactory
{
    T Create<T>(IEnumerable<Page> pages) where T : MasterViewData, new();
}

public class ViewDataFactory : IViewDataFactory
{        
    public T Create<T>(IEnumerable<Page> pages) where T : MasterViewData, new()
    {
        T t = new T();
        t.Pages = pages;
        return t;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!