Exemple #1
0
        public PropertyService(DirectoryName configDirectory, DirectoryName dataDirectory, string propertiesName)
        {
            DataDirectory      = dataDirectory;
            ConfigDirectory    = configDirectory;
            PropertiesFileName = configDirectory.CombineFile(propertiesName + ".xml");

            _userSettings       = InternalLoadUserSettingsBag(PropertiesFileName);
            ApplicationSettings = new PropertyBag()
            {
                ParentObject = SuspendableDocumentNode.StaticInstance
            };
            BuiltinSettings = new PropertyBag()
            {
                ParentObject = SuspendableDocumentNode.StaticInstance
            };
        }
Exemple #2
0
 protected virtual PropertyBagLazyLoaded InternalLoadUserSettingsBag(FileName fileName)
 {
     if (!File.Exists(fileName))
     {
         var result = new PropertyBagLazyLoaded()
         {
             ParentObject = SuspendableDocumentNode.StaticInstance
         };
         return(result);
     }
     try
     {
         using (LockPropertyFile())
         {
             using (var str = new Altaxo.Serialization.Xml.XmlStreamDeserializationInfo())
             {
                 str.BeginReading(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read));
                 var result = (PropertyBagLazyLoaded)str.GetValue("UserSettings", null);
                 result.ParentObject = SuspendableDocumentNode.StaticInstance;
                 str.EndReading();
                 return(result);
             }
         }
     }
     catch (XmlException ex)
     {
         Altaxo.Current.MessageService.ShowError("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.");
     }
     catch (IOException ex)
     {
         Altaxo.Current.MessageService.ShowError("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.");
     }
     catch (Exception ex)
     {
         Altaxo.Current.MessageService.ShowError("Error loading properties: " + ex.Message + "\nSettings have been restored to default values.");
     }
     return(new PropertyBagLazyLoaded()
     {
         ParentObject = SuspendableDocumentNode.StaticInstance
     });
 }