我有一個對象,我們稱之爲Sprite
,它有一個叫做SpriteImages
的Dictionary<string, SpriteMapImageWrapper>
。關鍵是一個字符串,它需要被存儲在映射的對象中。這本詞典需要映射到一個單位List<SpriteMapImageInfo>
。所有其他屬性都是相同的,但字典密鑰需要映射到SpriteMapImageInfo.Key
。這可能使用AutoMapper?使用AutoMapper將字典映射到列表並存儲它的密鑰
public class SpriteMapImageWrapper
{
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
public class SpriteMapImageInfo
{
public string Key { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}