"Cannot convert source type IAPISession to target type FacebookSession"
为什么会这样?Facebook不就是IAPISession吗?我想到的是多态,所以这种比较应该没问题。但我不确定。
public class FacebookSession : IAPISession
{
private FacebookSession currentSession;
private FacebookSession()
{
currentSession = GetCurrentSession();
}
...more code
public IAPISession GetCurrentSession()
{
// my logic is here...whatever that may be
}
... more code
}
Updated
here's my actual interface:
public interface IAPISession
{
#region Properties
int SessionID { get; }
string UserID { get; }
bool SessionHasExpired { get; }
DateTime ExpirationDate { get; }
void LogOut(); // expires the session & sets SessionHasExpired
#endregion Properties
#region Methods
IAPISession GetCurrentSession();
#endregion Methods
}
这个接口将被用于我们的任何API包装器项目(例如FlickrSession等)。