public static CfgEncoder Encode(this ICfg cfg, ICfgSerializeNestedReferences keeper) { var prevKeeper = CfgEncoder.keeper; CfgEncoder.keeper = keeper; var ret = cfg.Encode(); CfgEncoder.keeper = prevKeeper; return(ret); }
public CfgEncoder Add <T>(string tag, List <T> other, ICfgSerializeNestedReferences referencesKeeper) where T : ICfg, new() { var prevKeeper = keeper; keeper = referencesKeeper; Add(tag, other); keeper = prevKeeper; return(this); }
public CfgEncoder TryAdd <T>(string tag, T obj, ICfgSerializeNestedReferences referencesKeeper) { var prevKeeper = keeper; keeper = referencesKeeper; TryAdd(tag, obj); keeper = prevKeeper; return(this); }
public static List <T> Decode_List <T>(this string data, out List <T> val, ICfgSerializeNestedReferences referencesKeeper, ref ListMetaData ld) where T : ICfg, new() { var prevKeeper = Keeper; Keeper = referencesKeeper; data.Decode_List(out val, ref ld); Keeper = prevKeeper; return(val); }
public CfgEncoder Add(string tag, ICfg other, ICfgSerializeNestedReferences referencesKeeper) { var prevKeeper = keeper; keeper = referencesKeeper; Add(tag, other); keeper = prevKeeper; return(this); }
public static bool TryDecodeInto <T>(this string data, T val, ICfgSerializeNestedReferences referencesKeeper) { var std = QcUnity.TryGet_fromObj <ICfg>(val); if (std == null) { return(false); } data.DecodeInto(std, referencesKeeper); return(true); }
public static CfgEncoder Encode(this ICfg cfg, ICfgSerializeNestedReferences keeper) { var prevKeeper = CfgEncoder.keeper; CfgEncoder.keeper = keeper; var ret = cfg.Encode(); (keeper as UnityEngine.Object).SetToDirty(); CfgEncoder.keeper = prevKeeper; return(ret); }
public CfgEncoder Add_References <T>(string tag, List <T> lst, ICfgSerializeNestedReferences referencesKeeper) where T : Object { if (referencesKeeper == null || lst == null) { return(this); } var indxs = new List <int>(); foreach (var o in lst) { indxs.Add(referencesKeeper.GetReferenceIndex(o)); } return(Add(tag, indxs)); }
public static bool DecodeInto <T>(this string data, T val, ICfgSerializeNestedReferences referencesKeeper) where T : ICfg { if (val == null) { return(false); } var prevKeeper = Keeper; Keeper = referencesKeeper; val.Decode(data); Keeper = prevKeeper; return(true); }
public static T Decode <T>(this string data, ref T val, ICfgSerializeNestedReferences referencesKeeper) where T : UnityEngine.Object { if (referencesKeeper == null) { return(val); } var ind = data.ToInt(); var getting = referencesKeeper.GetReferenced <T>(ind); if (getting != null) { val = getting; } return(val); }
public static T CloneCfg <T>(this T obj, ICfgSerializeNestedReferences nested = null) where T : ICfg { if (QcUnity.IsNullOrDestroyed_Obj(obj)) { return(default(T)); } var ret = (T)Activator.CreateInstance(obj.GetType()); if (nested != null) { obj.Encode(nested).ToString().DecodeInto(ret, nested); } else { ret.Decode(obj.Encode().ToString()); } return(ret); }
public static T CloneCfg <T>(this T obj, ICfgSerializeNestedReferences nested = null) where T : ICfg { if (QcUnity.IsNullOrDestroyed_Obj(obj)) { return(default);
public CfgEncoder Add_Reference(string tag, Object obj, ICfgSerializeNestedReferences referencesKeeper) => (referencesKeeper == null || !obj) ? this : Add_IfNotNegative(tag, referencesKeeper.GetReferenceIndex(obj));
public static T DecodeInto <T>(this string data, out T val, ICfgSerializeNestedReferences referencesKeeper) where T : ICfg, new() { val = data.DecodeInto <T>(referencesKeeper); return(val); }
public static List <T> Decode_References <T>(this string data, out List <T> list, ICfgSerializeNestedReferences referencesKeeper) where T : UnityEngine.Object { list = new List <T>(); if (referencesKeeper == null) { return(list); } List <int> indexes; data.Decode_List(out indexes); foreach (var i in indexes) { list.Add(referencesKeeper.GetReferenced <T>(i)); } return(list); }
public static bool Decode(this ICfg cfg, string data, ICfgSerializeNestedReferences keeper) => data.DecodeInto(cfg, keeper);