// TODO: Need to actually do Loading for cache "miss" public MCgData LoadData(FECgAssetType assetType, string shortCode) { if (Map[assetType].ContainsKey(shortCode)) { return(Map[assetType][shortCode]); } FCgDebug.LogWarning("MCgDataMapping.LoadData: No " + assetType.Name + " with ShortCode: " + shortCode); return(null); }
public virtual void Init() { AssetType = EMCgAssetType.Get().GetSafeEnum(S_AssetType.Name); /* * Dictionary<string, FieldInfo> serializedFields = new Dictionary<string, FieldInfo>(); * Dictionary<string, FieldInfo> nonSerializedFields = new Dictionary<string, FieldInfo>(); * * Type type = this.GetType(); * * FieldInfo[] fieldinfos = type.GetFields(); * * foreach (FieldInfo f in fieldinfos) * { * object[] attributes = f.GetCustomAttributes(true); * * foreach (object a in attributes) * { * // SerializeField * if (a.GetType() == typeof(SerializeField)) * serializedFields.Add(f.Name, f); * // NonSerializedAttribute * else * if (a.GetType() == typeof(NonSerializedAttribute)) * nonSerializedFields.Add(f.Name, f); * } * } * * Dictionary<string, FieldInfo>.KeyCollection fieldNames = serializedFields.Keys; * * foreach (string name in fieldNames) * { * // Prefix with S_ * if (name.StartsWith("S_")) * { * string ns_name = name.Replace("S_", ""); * * FieldInfo sf = serializedFields[name]; * FieldInfo nsf = nonSerializedFields[ns_name]; * } * } */ }
public void GenerateMap <DataType>(FECgAssetType assetType, ref List <DataType> list, ref Dictionary <string, DataType> map, bool intialize = false) where DataType : MCgData { if (intialize) { if (list == null) { list = new List <DataType>(); } map = new Dictionary <string, DataType>(); } foreach (DataType d in list) { map.Add(d.ShortCode, d); Map[assetType].Add(d.ShortCode, d); } }
public T GetData <T>(FECgAssetType assetType, string shortCode) where T : MCgData { return((T)GetData(assetType, shortCode)); }