Example #1
0
 public bool LoadPartialConfig(ref string partialConfigXml)
 {
     if (string.IsNullOrEmpty(partialConfigXml))
     {
         var partialConfigFile = FindPartialConfigFile();
         if (partialConfigFile == null)
             return true;
         try
         {
             using (var reader = partialConfigFile.OpenText())
                 partialConfigXml = reader.ReadToEnd();
         }
         catch (Exception ex)
         {
             Logger.LogError(Message.ConfigReadPartialError, ex);
             return false;
         }
     }
     try
     {
         if (_mergeUtil.Merge(partialConfigXml, _currentConfigXml))
         {
             string resXml;
             using (var memStream = new MemoryStream())
             {
                 using (var xmlWriter = new PrettyPrintXmlWriter(memStream))
                 {
                     _mergeUtil.Result.WriteTo(xmlWriter);
                     resXml = xmlWriter.ToFormatString();
                 }
             }
             _currentConfig = ApplicationConfig.FromXml(resXml);
             _currentConfigXml = resXml;
         }
         return true;
     }
     catch (Exception ex)
     {
         Logger.LogError(Message.ConfigLoadPartialError, ex);
         return false;
     }
 }
Example #2
0
 public string ToXml()
 {
     using (var memStream = new MemoryStream())
     {
         using (var xmlWriter = new PrettyPrintXmlWriter(memStream))
         {
             SerializeToXmlElement(xmlWriter, SECTION_NAME);
             return xmlWriter.ToFormatString();
         }
     }
 }