protected Pane(string label, string path, SettingsScope scope, IHasSettings settingsContainer) : base(path, scope) { this.label = label; this.settingsContainer = settingsContainer; settingsContainer?.Load(); }
/// <summary> /// Deep load and populate settings values for entity and all nested objects /// </summary> /// <param name="manager"></param> /// <param name="entity"></param> /// <param name="excludeHidden"></param> /// <returns></returns> public static Task DeepLoadSettingsAsync(this ISettingsManager manager, IHasSettings entity, bool excludeHidden) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } return(DeepLoadSettingsAsyncImpl(manager, entity, excludeHidden)); }
public static void LoadSettingsToGallery(IHasSettings gallery) { Dictionary <string, string> settingsDict; var pathToSettings = Path.Combine(Application.dataPath, "settings.txt"); if (TryLoadSettings(out settingsDict, pathToSettings)) { gallery.CustomPicturesFolderSet = settingsDict["CustomFolderSet"] == "true"; print("CustomFolderSet = " + gallery.CustomPicturesFolderSet.ToString()); gallery.CustomPicturesFolderPath = settingsDict["CustomFolderPath"]; print("CustomPicturesFolderPath = " + gallery.CustomPicturesFolderPath); gallery.PaintCorridors = settingsDict["PaintCorridors"] == "true"; print("PaintCorridors = " + gallery.PaintCorridors.ToString()); gallery.PaintRooms = settingsDict["PaintRooms"] == "true"; print("PaintRooms = " + gallery.PaintRooms.ToString()); } }
/// <summary> /// Deep remove entity and all nested objects settings values /// </summary> public static async Task DeepRemoveSettingsAsync(this ISettingsManager manager, IHasSettings entry) { await manager.DeepRemoveSettingsAsync(new[] { entry }); }
/// <summary> /// Deep load and populate settings values for entity and all nested objects /// </summary> /// <param name="entity"></param> public static async Task DeepLoadSettingsAsync(this ISettingsManager manager, IHasSettings entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } //Deep load settings values for all object contains settings var hasSettingsObjects = entity.GetFlatObjectsListWithInterface <IHasSettings>(); foreach (var hasSettingsObject in hasSettingsObjects) { var typeSettings = manager.GetSettingsForType(hasSettingsObject.TypeName); if (typeSettings.IsNullOrEmpty()) { throw new SettingsTypeNotRegisteredException(hasSettingsObject.TypeName); } hasSettingsObject.Settings = (await manager.GetObjectSettingsAsync(typeSettings.Select(x => x.Name), hasSettingsObject.TypeName, hasSettingsObject.Id)).ToList(); } }
/// <summary> /// Deep remove entity and all nested objects settings values /// </summary> /// <param name="entity"></param> public static async Task DeepRemoveSettingsAsync(this ISettingsManager manager, IHasSettings entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (string.IsNullOrEmpty(entity.Id)) { throw new ArgumentException("entity must have Id"); } var haveSettingsObjects = entity.GetFlatObjectsListWithInterface <IHasSettings>(); await manager.RemoveObjectSettingsAsync(haveSettingsObjects.SelectMany(x => x.Settings).Distinct()); }
/// <summary> /// Deep save entity and all nested objects settings values /// </summary> /// <param name="entity"></param> public static async Task DeepSaveSettingsAsync(this ISettingsManager manager, IHasSettings entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (string.IsNullOrEmpty(entity.Id)) { throw new ArgumentException("entity must have Id"); } var forSaveSettings = new List <ObjectSettingEntry>(); var haveSettingsObjects = entity.GetFlatObjectsListWithInterface <IHasSettings>(); foreach (var haveSettingsObject in haveSettingsObjects.Where(x => x.Settings != null)) { //Save settings foreach (var setting in haveSettingsObject.Settings) { setting.ObjectId = haveSettingsObject.Id; setting.ObjectType = haveSettingsObject.TypeName; forSaveSettings.Add(setting); } } if (forSaveSettings.Any()) { await manager.SaveObjectSettingsAsync(forSaveSettings); } }
/// <summary> /// Deep load and populate settings values for entity and all nested objects /// </summary> /// <param name="entity"></param> public static async Task DeepLoadSettingsAsync(this ISettingsManager manager, IHasSettings entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (string.IsNullOrEmpty(entity.Id)) { throw new ArgumentException("entity must have Id"); } //Deep load settings values for all object contains settings var haveSettingsObjects = entity.GetFlatObjectsListWithInterface <IHasSettings>(); foreach (var haveSettingsObject in haveSettingsObjects.Where(x => x.Settings != null)) { haveSettingsObject.Settings = (await manager.GetObjectSettingsAsync(haveSettingsObject.Settings.Select(x => x.Name), haveSettingsObject.TypeName, haveSettingsObject.Id)).ToList(); } }
private static async Task DeepLoadSettingsAsyncImpl(ISettingsManager manager, IHasSettings entity, bool excludeHidden) { //Deep load settings values for all object contains settings var hasSettingsObjects = entity.GetFlatObjectsListWithInterface <IHasSettings>(); foreach (var hasSettingsObject in hasSettingsObjects) { var typeSettings = manager.GetSettingsForType(hasSettingsObject.TypeName); if (typeSettings.IsNullOrEmpty()) { throw new SettingsTypeNotRegisteredException(hasSettingsObject.TypeName); } if (excludeHidden) { typeSettings = typeSettings.Where(x => !x.IsHidden); } hasSettingsObject.Settings = (await manager.GetObjectSettingsAsync(typeSettings.Select(x => x.Name), hasSettingsObject.TypeName, hasSettingsObject.Id)).ToList(); } }
/// <summary> /// Deep load and populate settings values for entity and all nested objects /// </summary> /// <param name="manager"></param> /// <param name="entity"></param> public static async Task DeepLoadSettingsAsync(this ISettingsManager manager, IHasSettings entity) { await DeepLoadSettingsAsync(manager, entity, true); }
internal static void Save(this IHasSettings settings) { settings.Save(); }
protected internal ProjectSettingsPane(string label, IHasSettings settings) : base(label, "Project/" + label, SettingsScope.Project, settings) { }