【发布时间】:2013-01-23 18:29:38
【问题描述】:
我有一个如下创建的列表。它使用第三方包装器来管理从电脑游戏下载 xml 信息:-
List<EveAI.Live.Asset> lst_eveai_characterabc_assets = eve_api.GetCharacterAssets();
Asset 的类定义是:-
namespace EveAI.Live
{
[TypeConverter(typeof(ExpandableObjectConverter))]
public class Asset
{
public Asset();
public ContainerType Container { get; set; }
public List<Asset> Contents { get; set; }
public double ContentsVolume { get; }
public bool IsSingleton { get; set; }
public long ItemID { get; set; }
[Obsolete("Will be removed in a future version, use LocationStation or
LocationSolarsystem or LocationConquerableStation instead")]
public Station Location { get; set; }
public ConquerableStation LocationConquerableStation { get; set; }
public int LocationID { get; set; }
public SolarSystem LocationSolarsystem { get; set; }
public Station LocationStation { get; set; }
public long Quantity { get; set; }
public int RawQuantity { get; set; }
public ProductType Type { get; set; }
public int TypeID { get; set; }
public override string ToString();
}
}
我想将列表 lst_eveai_characterabc_assets 复制到使用类 AssetUniverseIDs 的新列表 - 继承类 EveAI.Live.Asset 类似的东西:-
public class AssetUniverseIDs : EveAI.Live.Asset
{
public Int32 stationID {get;set;}
public Int32 stationTypeID { get; set; }
public Int32 corporationID { get; set; }
public Int32 solarSystemID { get; set; }
public string solarSystemName { get; set; }
public double security { get; set; }
public string securityClass { get; set; }
public Int32 constellationID { get; set; }
public Int32 regionID { get; set; }
public string regionName { get; set; }
public string stationName { get; set; }
}
但到目前为止,我无法将 lst_eveai_characterabc_assets 复制到使用继承类 Assets 的类 AssetUniverseIDs 的新列表中。请问我怎样才能做到这一点。
【问题讨论】:
-
您介意通过删除不必要的成员来制作更小的样本并尝试更改名称以遵循默认的 C# 约定吗?
-
这看起来像是在为游戏 Eve 构建一个机器人,我认为这违反了他们的服务条款。
-
所以你需要继承 AssetUniverseIDs 的“lst_eveai_characterabc_assets”类的所有实例?
-
Re Malcolm - 管理 EVE 的公司 - CCP 提供了一个广泛的 API,允许程序员下载有关字符的 xml 信息。一般规则是,只要不对其他玩家造成不公平,就可以获取和管理角色数据。对于我正在做的事情,获取我的游戏角色资产数据是可以的。我正在使用 EveAI 包装器,它管理 xml 数据的较低级别下载及其缓存时间。