-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
4>Model.NinoGen.Serializer.Generic.g.cs(62,68): Error CS1503 : 参数 1: 无法从“方法组”转换为“Nino.Core.SerializeDelegate<ET.SyncList<long>>”
[BsonSerializer(typeof(BsonSyncListSerializer<>))]
public interface ISyncList<T> : IList<T>
{
public void Set(IList<T> list);
public void ApplyValue(byte opType, byte[] keyVal, byte[] fieldVal);
public int FindIndex(Predicate<T> match);
}
[EnableClass]
[MemoryPackable(GenerateType.Collection)]
[NinoType]
public partial class SyncList<T> : List<T>, ISyncList<T>
{
[MemoryPackIgnore]
[NinoIgnore]
[BsonIgnore]
private Entity ParentComponent; //隶属组件
[MemoryPackIgnore]
[NinoIgnore]
[BsonIgnore]
private string FieldName; //对应字段名
[MemoryPackIgnore]
[NinoIgnore]
[BsonIgnore]
private SyncFlag SyncFlag; //同步方式
[BsonIgnore]
[MemoryPackIgnore]
[NinoIgnore]
private int Offset; //字段Index
[BsonIgnore]
[MemoryPackIgnore]
[NinoIgnore]
private bool HadInit;
public SyncList()
{
}
public SyncList(int capacity) : base(capacity)
{
}
public SyncList(IEnumerable<T> collection) : base(collection)
{
}
public void Init(Entity parentComponent, string fieldName, SyncFlag syncFlag, int offset)
{
if (this.HadInit)
{
return;
}
this.HadInit = true;
this.ParentComponent = parentComponent;
this.FieldName = fieldName;
this.SyncFlag = syncFlag;
this.Offset = offset;
}
public new T this[int index]
{
get => base[index];
set
{
base[index] = value;
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, value, index, SyncOpType.eSetByKey);
}
}
}
public new void Add(T value)
{
base.Add(value);
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, value, null, SyncOpType.eAdd);
}
}
public new void Clear()
{
base.Clear();
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, (T)default, 0, SyncOpType.eClear);
}
}
public new bool Remove(T val)
{
if (base.Remove(val))
{
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, val, null, SyncOpType.eRemove);
}
return true;
}
return false;
}
public new void Insert(int index, T val)
{
base.Insert(index, val);
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, val, index, SyncOpType.eInsert);
}
}
public new void RemoveAt(int index)
{
var var = base[index];
base.RemoveAt(index);
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, (T)var, index, SyncOpType.eRemoveAt);
}
}
public void Set(IList<T> list)
{
base.Clear();
base.AddRange(list);
if (ParentComponent != null)
{
ParentComponent.PublishProperty(FieldName, Offset, (int)SyncFlag, list, 0, SyncOpType.eSet);
}
}
public void ApplyValue(byte opType, byte[] keyVal, byte[] fieldVal)
{
int index = keyVal == null ? -1 : (int)NinoHelper.Deserialize(typeof(int), keyVal);
T value = default;
if ((SyncOpType)opType != SyncOpType.eSet)
value = fieldVal == null ? default : (T)NinoHelper.Deserialize(typeof(T), fieldVal);
switch ((SyncOpType)opType)
{
case SyncOpType.eAdd:
this.Add(value);
break;
case SyncOpType.eRemove:
this.Remove(value);
break;
case SyncOpType.eRemoveAt:
this.RemoveAt(index);
break;
case SyncOpType.eClear:
this.Clear();
break;
case SyncOpType.eSetByKey:
this[index] = value;
break;
case SyncOpType.eInsert:
this.Insert(index, value);
break;
case SyncOpType.eSet:
IList<T> var = (IList<T>)NinoHelper.Deserialize(typeof(IList<T>), fieldVal);
this.Set(var);
break;
default:
break;
}
}
}Metadata
Metadata
Assignees
Labels
No labels