TH1/Share/Tool/Template.txt
2025-07-17 18:26:28 +08:00

65 lines
1.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;
using System.ComponentModel;
namespace ET
{
[Config]
public partial class (ConfigName)Category : Singleton<(ConfigName)Category>, IMerge
{
[BsonElement]
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
private Dictionary<int, (ConfigName)> dict = new();
public void Merge(object o)
{
(ConfigName)Category s = o as (ConfigName)Category;
foreach (var kv in s.dict)
{
this.dict.Add(kv.Key, kv.Value);
}
}
public (ConfigName) Get(int id)
{
this.dict.TryGetValue(id, out (ConfigName) item);
if (item == null)
{
throw new Exception($"配置找不到,配置表名: {nameof ((ConfigName))}配置id: {id}");
}
return item;
}
public bool Contain(int id)
{
return this.dict.ContainsKey(id);
}
public Dictionary<int, (ConfigName)> GetAll()
{
return this.dict;
}
public (ConfigName) GetOne()
{
if (this.dict == null || this.dict.Count <= 0)
{
return null;
}
var enumerator = this.dict.Values.GetEnumerator();
enumerator.MoveNext();
return enumerator.Current;
}
}
public partial class (ConfigName): ProtoObject, IConfig
{
(Fields)
}
}