// 回收所有属性对象到对象池中. virtual public void RecycleAllAttribute() { Dictionary <int, GKCommonValue> .Enumerator it = _attrDict.GetEnumerator(); while (it.MoveNext()) { GKCommonValue attr = it.Current.Value; if (null != attr) { attr.Clear(); GKCommonValue.commonValuePool.Recycle(attr); } } _attrDict.Clear(); Dictionary <int, GKCommonListValue> .Enumerator it_ = _attrListDict.GetEnumerator(); while (it.MoveNext()) { GKCommonListValue attr = it_.Current.Value; if (null != attr) { attr.Clear(); GKCommonListValue.commonValuePool.Recycle(attr); } } _attrListDict.Clear(); }
public GKCommonListValue CopyAttribute(GKCommonListValue src, GKCommonListValue dest, bool bDoEvent) { dest.CopyVale(src); if (bDoEvent) { dest.DoEvent(this); } return(dest); }
public GKCommonListValue CopyAttribute(int idx, GKCommonListValue src, bool bDoEvent) { GKCommonListValue attr = GetOrCreateAttributeList((int)idx); if (null == attr) { return(null); } return(CopyAttribute(attr, src, bDoEvent)); }
public void CopyVale(GKCommonListValue src, bool bDoEvent = false) { if (null != src) { _longValue = src._longValue; _floatValue = src._floatValue; _stringValue = src._stringValue; _bufferValue = src._bufferValue; type = src.type; } }
public GKCommonListValue SetAttributeList(int idx, List <string> value, bool bDoEvent) { GKCommonListValue attr = GetOrCreateAttributeList((int)idx); if (null == attr) { return(null); } attr.SetValue(value); if (bDoEvent) { attr.DoEvent(this); } return(attr); }
string _GetCurValueToString(GKCommonListValue data) { string content = ""; switch (data.type) { case AttributeType.Type_Int8: case AttributeType.Type_Int16: case AttributeType.Type_Int32: foreach (var d in data.ValInt) { content += string.Format("{0}%%%", d); } break; case AttributeType.Type_Int64: foreach (var d in data.ValLong) { content += string.Format("{0}%%%", d); } break; case AttributeType.Type_Float: case AttributeType.Type_Double: foreach (var d in data.ValFloat) { content += string.Format("{0}%%%", d); } break; case AttributeType.Type_String: foreach (var d in data.ValString) { content += string.Format("{0}%%%", d); } break; case AttributeType.Type_Blob: foreach (var d in data.ValBuffer) { content += string.Format("{0}%%%", d.ToString()); } break; } return(content); }
virtual public GKCommonListValue GetOrCreateAttributeList(int idx) { GKCommonListValue attr = null; if (!_attrListDict.TryGetValue(idx, out attr) || null == attr) { attr = GKCommonListValue.commonValuePool.Spawn(true); // 如果取出来的对象存在监听, 意味着对象仍旧存在外部代理或同一个对象呗多次放回内存池中. // 为了避免意外情况发生, 抛弃此对象使用. 重新获取. while (attr.HasEvent()) { Debug.LogWarning(string.Format("GetOrCreateAttribute target still has event. target: {0}", attr.GetEventTarget())); attr = GKCommonListValue.commonValuePool.Spawn(true); } attr.index = idx; _attrListDict[idx] = attr; } return(attr); }
// 清空所有属性值, 绑定事件不清楚. (用途类似游戏中断线重连等) virtual public void ClearAllAttributeValue() { Dictionary <int, GKCommonValue> .Enumerator it = _attrDict.GetEnumerator(); while (it.MoveNext()) { GKCommonValue attr = it.Current.Value; if (null != attr) { attr.ClearValueWithOutEvent(); } } Dictionary <int, GKCommonListValue> .Enumerator it_ = _attrListDict.GetEnumerator(); while (it_.MoveNext()) { GKCommonListValue attr = it_.Current.Value; if (null != attr) { attr.ClearValueWithOutEvent(); } } }
public GKCommonListValue SetAttributeList(int idx, string value, bool bDoEvent, bool bRemove = false) { GKCommonListValue attr = GetOrCreateAttributeList((int)idx); if (null == attr) { return(null); } if (!bRemove) { attr.AddValue(value); } else { attr.RemoveValue(value); } if (bDoEvent) { attr.DoEvent(this); } return(attr); }