/// <summary> /// Implement a <see cref="ISettingsLogger{T}"/> of your own and pass in to the logger. <br></br> /// It'll help you to create an instance of <see cref="SettingsClassInstance"/> and register the <c>ErrorOccurs</c> event for your custom setting logger. /// </summary> /// <param name="customSettingsLogger"></param> public SettingsLoggerFactory <TClass> UseCustomSettingsLogger(ISettingsLogger <TClass> customSettingsLogger) { SettingsLogger = customSettingsLogger; SettingsLogger.SettingsClassInstance = CommonFunctions.ActivateClass <TClass>(); SettingsLogger.ErrorOccurs += _settingsLogger_ErrorOccurs; // Chain the method return(this); }
public JetBoxSettingsStorage(Lifetime lifetime, ProductSettingsLocation productSettingsLocation, ISettingsSchema settingsSchema, DataContexts dataContexts, IThreading threading, IFileSystemTracker fileSystemTracker, FileSettingsStorageBehavior settingsStorageBehavior, ISettingsLogger settingsLogger, ISettingsChangeDispatch settingsChangeDispatch, SettingsStorageMountPoints.SelfCheckControl selfCheckControl) { var filePath = productSettingsLocation.GetUserSettingsNonRoamingDir(ProductSettingsLocationFlag.ThisProductThisVersionThisEnvironment).Combine("JetBox" + XmlFileSettingsStorage.SettingsStorageFileExtensionWithDot); var property = new Property<FileSystemPath>(lifetime, GetType().Name + "Path", filePath); var settingsProvider = new JetBoxSettingsProvider(lifetime, GetType().Name + "::Provider", property, true, 0, IsAvailable.Always, SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, fileSystemTracker, settingsStorageBehavior, new Dictionary<PropertyId, object>()); var mounts = new SettingsStorageMountPoints(lifetime, new CollectionEvents<IProvider<ISettingsStorageMountPoint>>(lifetime, GetType() + "::Mounts") { settingsProvider }, threading, settingsLogger, selfCheckControl); mySettingsStore = new SettingsStore(lifetime, settingsSchema, mounts, dataContexts, null, settingsLogger, settingsChangeDispatch ); }
/// <summary> /// Use a settings logger with built-in format. /// </summary> /// <param name="format">The format of the logger.</param> /// <param name="schema">The schema that will be used to validate the settings file when read. Leave it null if you don't need it.</param> /// <returns></returns> public SettingsLoggerFactory <TClass> UseBuiltInFormatSettingsLogger(SettingsFileFormat format, string schema = null) { switch (format) { case SettingsFileFormat.JSON: SettingsLogger = new JsonSettingsLogger <TClass>(Filename, schema); break; case SettingsFileFormat.INI: SettingsLogger = new IniSettingsLogger <TClass>(Filename); break; } SettingsLogger.ErrorOccurs += _settingsLogger_ErrorOccurs; // Chain the method return(this); }
public JetBoxSettingsStorage(Lifetime lifetime, ProductSettingsLocation productSettingsLocation, ISettingsSchema settingsSchema, DataContexts dataContexts, IThreading threading, IFileSystemTracker fileSystemTracker, IFileSettingsStorageBehavior settingsStorageBehavior, ISettingsLogger settingsLogger, ISettingsChangeDispatch settingsChangeDispatch, SettingsStorageMountPoints.SelfCheckControl selfCheckControl, InternKeyPathComponent interned) { var filePath = productSettingsLocation.GetUserSettingsNonRoamingDir(ApplicationHostDetails.PerHostAndWave).Combine("JetBox" + XmlFileSettingsStorage.SettingsStorageFileExtensionWithDot); var property = new Property <FileSystemPath>(lifetime, GetType().Name + "Path", filePath); var settingsProvider = new JetBoxSettingsProvider(lifetime, GetType().Name + "::Provider", property, true, 0, IsAvailable.Always, SettingsStoreSerializationToXmlDiskFile.SavingEmptyContent.DeleteFile, threading, fileSystemTracker, settingsStorageBehavior, interned, new Dictionary <PropertyId, object>()); var mounts = new SettingsStorageMountPoints(lifetime, new CollectionEvents <IProvider <ISettingsStorageMountPoint> >(lifetime, GetType() + "::Mounts") { settingsProvider }, threading, settingsLogger, selfCheckControl); mySettingsStore = new SettingsStore(lifetime, settingsSchema, mounts, dataContexts, null, settingsLogger, settingsChangeDispatch); }