You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
130 lines
3.3 KiB
130 lines
3.3 KiB
using System; |
|
using System.Collections.Generic; |
|
using MongoDB.Bson.Serialization.Attributes; |
|
using ProtoBuf; |
|
|
|
namespace ET |
|
{ |
|
[ProtoContract] |
|
[Config] |
|
public partial class CropConfigCategory : ProtoObject, IMerge |
|
{ |
|
public static CropConfigCategory Instance; |
|
|
|
[ProtoIgnore] |
|
[BsonIgnore] |
|
private Dictionary<int, CropConfig> dict = new Dictionary<int, CropConfig>(); |
|
|
|
[BsonElement] |
|
[ProtoMember(1)] |
|
private List<CropConfig> list = new List<CropConfig>(); |
|
|
|
public CropConfigCategory() |
|
{ |
|
Instance = this; |
|
} |
|
|
|
public void Merge(object o) |
|
{ |
|
CropConfigCategory s = o as CropConfigCategory; |
|
this.list.AddRange(s.list); |
|
} |
|
|
|
public override void EndInit() |
|
{ |
|
foreach (CropConfig config in list) |
|
{ |
|
config.EndInit(); |
|
this.dict.Add(config.Id, config); |
|
} |
|
this.AfterEndInit(); |
|
} |
|
|
|
public CropConfig Get(int id) |
|
{ |
|
this.dict.TryGetValue(id, out CropConfig item); |
|
|
|
if (item == null) |
|
{ |
|
throw new Exception($"配置找不到,配置表名: {nameof (CropConfig)},配置id: {id}"); |
|
} |
|
|
|
return item; |
|
} |
|
|
|
public bool Contain(int id) |
|
{ |
|
return this.dict.ContainsKey(id); |
|
} |
|
|
|
public Dictionary<int, CropConfig> GetAll() |
|
{ |
|
return this.dict; |
|
} |
|
|
|
public List<CropConfig> GetList() |
|
{ |
|
return this.list; |
|
} |
|
|
|
public CropConfig GetOne() |
|
{ |
|
if (this.dict == null || this.dict.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
return this.dict.Values.GetEnumerator().Current; |
|
} |
|
} |
|
|
|
[ProtoContract] |
|
public partial class CropConfig: ProtoObject, IConfig |
|
{ |
|
/// <summary>编号</summary> |
|
[ProtoMember(1)] |
|
public int Id { get; set; } |
|
/// <summary>名称</summary> |
|
[ProtoMember(2)] |
|
public string Name { get; set; } |
|
/// <summary>季节</summary> |
|
[ProtoMember(3)] |
|
public int[] Season { get; set; } |
|
/// <summary>农田类型</summary> |
|
[ProtoMember(4)] |
|
public int FieldType { get; set; } |
|
/// <summary>种子需求</summary> |
|
[ProtoMember(5)] |
|
public int SeedNeed { get; set; } |
|
/// <summary>种子数量</summary> |
|
[ProtoMember(6)] |
|
public int SeedNum { get; set; } |
|
/// <summary>成长周期</summary> |
|
[ProtoMember(7)] |
|
public int GrowthCycle { get; set; } |
|
/// <summary>产出类型</summary> |
|
[ProtoMember(8)] |
|
public int Type { get; set; } |
|
/// <summary>产品编号</summary> |
|
[ProtoMember(9)] |
|
public int ProductID { get; set; } |
|
/// <summary>基础产量</summary> |
|
[ProtoMember(10)] |
|
public int BasicProduction { get; set; } |
|
/// <summary>副产品类型</summary> |
|
[ProtoMember(11)] |
|
public int ByProductType { get; set; } |
|
/// <summary>副产品编号</summary> |
|
[ProtoMember(12)] |
|
public int ByProduct { get; set; } |
|
/// <summary>副产品基础产量</summary> |
|
[ProtoMember(13)] |
|
public int ByProductNum { get; set; } |
|
/// <summary>种子产出量</summary> |
|
[ProtoMember(14)] |
|
public int SeedProduce { get; set; } |
|
/// <summary>作物图片</summary> |
|
[ProtoMember(15)] |
|
public string CropPic { get; set; } |
|
|
|
} |
|
}
|
|
|