public static MetaWrapper <Tdata, Tmeta> Register(MetaWrapper <Tdata, Tmeta> meta) { if (_dataToMeta.ContainsKey(meta.Data)) { return(meta); } _dataToMeta[meta.Data] = meta; _metaToData[meta] = meta.Data; return(meta); }
/// <summary> /// Creates a new MetaWrapper and registers it with the cache /// </summary> /// <param name="data">The data object to wrap</param> /// <returns>The wrapped object cast back to the data type</returns> public static Tdata Create(Tdata data, Tmeta metaData) { if (_dataToMeta.ContainsKey(data)) { return(_dataToMeta[data]); } else { var wrapper = new MetaWrapper <Tdata, Tmeta> { Data = data, Meta = metaData }; _dataToMeta.Add(data, wrapper); _metaToData.Add(wrapper, data); return(wrapper); } }
public static MetaWrapper <Tdata, Tmeta> Clone(MetaWrapper <Tdata, Tmeta> meta) { var result = DeapClone <MetaWrapper <Tdata, Tmeta> > .Clone(meta); return(Register(result)); }