0
類型基本上我有實體:AutoMapper和繼承:解決由子字符串屬性
public abstract class SocialNetworkAccount
{
public virtual string AccessToken { get; set; }
public virtual string ProviderUserId { get; set; }
public virtual string UserName { get; set; }
}
和子類:
public class FacebookAccount : SocialNetworkAccount
{
public virtual string Name { get; set; }
public virtual string Link { get; set; }
public virtual GenderEnum Gender { get; set; }
}
public class LinkedInAccount : SocialNetworkAccount
{
public virtual string LastName { get; set; }
public virtual string FirstName { get; set; }
}
,我需要映射DotNetOpenAuth.AspNet.AuthenticationResult我的實體。
AuthenticationResult
具有字符串屬性Provider
AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication("...");
SocialNetworkAccount account = AutoMapper.Mapper.Map<SocialNetworkAccount>(result);
,但我需要的實例是FacebookAccount
或LinkedInAccount
依賴result.Provider
。 任何幫助
究竟'Provider'字符串包含?類型名稱? –
包含像「臉譜」一樣的字符串 – Roar