public void InitCollaction <T>(string staticFileName) where T : DataVO { StartInitialization(); T traceValue; LoggingManager.Log(typeof(T) + " Start initialization"); _collactionName = staticFileName; StaticResourcesXmlLoader <T> container = StaticResourcesXmlLoader <T> .LoadContainer(UrlXmls.staticData + staticFileName); _collaction = new Dictionary <string, IStaticData>(); _listOfAllNames = new List <string>(); foreach (T data in container.dataList) { if (!_collaction.ContainsKey(data.Name)) { _collaction.Add(data.Name, data); _listOfAllNames.Add(data.Name); } else { LoggingManager.AddErrorToLog("Repeated static data element with id " + data.Name); } } LoggingManager.Log(typeof(T) + " Finish initialization"); _initializationStatus = EnumInitializationStatus.initializated; }
public static StaticResourcesXmlLoader <T> LoadContainer(string xmlUrls) { TextAsset _xml = Resources.Load <TextAsset>(xmlUrls); if (_xml == null) { LoggingManager.AddErrorToLog("Didnt load xml " + xmlUrls); } StringReader reader = new StringReader(_xml.text); XmlSerializer serializer = new XmlSerializer(typeof(StaticResourcesXmlLoader <T>)); StaticResourcesXmlLoader <T> container = serializer.Deserialize(reader) as StaticResourcesXmlLoader <T>; reader.Close(); return(container); }