public void ClearConfigsFromFile <TKey, TValue>(string file, bool constConfig) where TValue : class { IXmlConfigDictionary <TKey> xmlDict = GetXmlDataCollection(typeof(TValue), typeof(TKey), constConfig) as IXmlConfigDictionary <TKey>; if (xmlDict != null) { xmlDict.ClearFileData(file); } }
public XmlConfigFile <TValue> LoadConfigsFromFile <TKey, TValue>(string xmlFile, bool constConfig) where TValue : class { Type elemType = typeof(TValue); IXmlConfigDictionary <TKey> xmlDict = GetXmlDataCollection(typeof(TValue), typeof(TKey), constConfig) as IXmlConfigDictionary <TKey>; if (xmlDict.ContainsFile(xmlFile)) { return(new XmlConfigFile <TKey, TValue>(xmlFile, xmlDict.GetFromFile <TValue>(xmlFile), constConfig)); } ReadXML(elemType, (name, type) => GetXmlFile(elemType, type, xmlFile)); return(new XmlConfigFile <TKey, TValue>(xmlFile, xmlDict.GetFromFile <TValue>(xmlFile), constConfig)); }
public bool SaveXml <TKey, TValue>(XmlConfigFile <TKey, TValue> file, bool constConfig) where TValue : class { IXmlConfigDictionary xmlDict = GetXmlDataCollection(typeof(TValue), typeof(TKey), constConfig); if (!string.IsNullOrEmpty(file.OriginPath) && file.OriginPath != file.Path) { xmlDict.DeleteFile(file.OriginPath); } if (!string.IsNullOrEmpty(file.Path)) { return(xmlDict.SaveToFile <TValue>(file.Path, file.Data)); } return(true); }
private void AppendData(Type collectionType, Type elemType, string name, MemberInfo keyField, Array data, string xmlPath) { if (TypeUtil.IsDictionary(collectionType)) { IXmlConfigDictionary xmlDict = GetXmlDataCollection(elemType, TypeUtil.GetDictionaryKeyType(collectionType), false); if (xmlDict != null) { xmlDict.Add(xmlPath, data, keyField); } } else { IXmlConfigDictionary xmlDict = GetXmlDataCollection(elemType, typeof(int), true); if (xmlDict != null) { xmlDict.Add(xmlPath, 0, (data as IList)[0]); } } }