private static Type GetActivatorType(Type settingsType, SettingsScope scope) { switch (scope) { case SettingsScope.Application: return typeof(ApplicationSettingsActivator<>).MakeGenericType(settingsType); case SettingsScope.User: return typeof(UserSettingsActivator<>).MakeGenericType(settingsType); default: throw new InvalidOperationException("Invalid settings scope"); } }
public String BuildKey(Type settings, SettingsScope scope, EmulationContext context) { if (scope == SettingsScope.None) throw new ApplicationException(String.Format("Could not create settings key for type {0}. Settings scope is set to 'None'", settings)); if ((scope & SettingsScope.Global) == SettingsScope.Global) return BuildKey(settings); if ((scope & SettingsScope.EmulatedSystem) == SettingsScope.EmulatedSystem) return BuildKey(settings, context.EmulatedSystem); if ((scope & SettingsScope.Game) == SettingsScope.Game) return BuildKey(settings, context.Game); if ((scope & SettingsScope.Override) == SettingsScope.Override) return "OVERRIDE " + settings.Name; throw new ApplicationException(String.Format("There was an error creating the settings key for type {0]", settings)); }
public static void Set <T>(string key, T value, SettingsScope scope = SettingsScope.Project) { instance.Set <T>(key, value, scope); }
public override SettingsStore GetReadOnlySettingsStore(SettingsScope scope) { throw new NotImplementedException(); }
public ARCoreAnalyticsProvider(string path, SettingsScope scope) : base(path, scope) { }
/// <summary> /// Gets the writable settings state. /// </summary> /// <param name="scope">The scope.</param> /// <returns>The writable settings state.</returns> public override WritableSettingsStore GetWritableSettingsStore(SettingsScope scope) { return new FakeWritableSettingsStore(); }
public override SettingsStore GetReadOnlySettingsStore(SettingsScope scope) => _store;
//const string k_MyCustomSettingsPath = "Assets/Editor/MyCustomSettings.asset"; public MyCustomSettingsProvider(string path, SettingsScope scope = SettingsScope.User) : base(path, scope) { }
GeneralProjectSettings(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, k_GeneralLabel, keywords) { }
//================================================================================ // 関数 //================================================================================ /// <summary> /// コンストラクタ /// </summary> public SceneViewRaycastTargetVisualizerSettingsProvider(string path, SettingsScope scope) : base(path, scope) { }
public DeveloperSetting(string path, SettingsScope scope) : base(path, scope) { }
public SettingsAttribute(SettingsScope scope) { Scope = scope; }
public SettingsRegistrationEntry(Type settingsType, Type targetType, SettingsScope scope) { SettingsType = settingsType; TargetType = targetType; Scope = scope; }
public SettingsScopeAttribute(SettingsScope settingsScope) { SettingsScope = settingsScope; }
public SettingsActivatorConfiguration(SettingsScope settingsScope, Type settingsType) { SettingsScope = settingsScope; SettingsType = settingsType; }
public static bool ContainsKey <T>(string key, SettingsScope scope = SettingsScope.Project) { return(instance.ContainsKey <T>(key, scope)); }
public AssetDBSettingProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { }
private NotificationSettingsProvider(string path, SettingsScope scopes) : base(path, scopes) { Initialize(); }
public TriLibSettingsProvider(string path, SettingsScope scopes = SettingsScope.User, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { }
public PreferencesProvider(string path, SettingsScope scope, Object targetObject) : base(path, scope) { _serializedObject = new SerializedObject(targetObject); }
/// <summary> /// Provides the <see cref="WritableSettingsStore"/> class for the requested scope which can be used both for /// reading and writing. /// </summary> /// <param name="scope">Requested scope.</param> /// <exception cref="ArgumentException">If the given scope is not a writable one.</exception> /// <returns><see cref="WritableSettingsStore"/> instance that can be used for accessing the scope.</returns> public override WritableSettingsStore GetWritableSettingsStore(SettingsScope scope) { IVsWritableSettingsStore writableSettingsStore; int hr = this.settingsManager.GetWritableSettingsStore((uint)scope, out writableSettingsStore); Marshal.ThrowExceptionForHR(hr); return new ShellWritableSettingsStore(writableSettingsStore); }
public void SetSettingsScope(string name, bool loadSettings) { lock (this) { int curID = _scope.ID; if (string.IsNullOrEmpty(name)) { name = "default"; } _scope = _database.FirstOrDefault<SettingsScope>("where Name=@0", name); if (_scope == null) { _scope = new SettingsScope(); _scope.Name = name; _database.Save(_scope); } _database.Execute("update Settings set Value=@0 where Name='Scope'", name); if (!TableExists(string.Format("Settings_{0}", _scope.ID))) { _database.Execute(string.Format("create table 'Settings_{0}' (Name text, Value text)", _scope.ID)); } if (loadSettings && curID != _scope.ID) { _currentSettings.Clear(); var settings = _database.Fetch<Setting>(string.Format("select * from Settings_{0}", _scope.ID)); foreach (var s in settings) { _currentSettings.Add(s.Name, s.Value); } } } }
public override SettingsStore GetReadOnlySettingsStore(SettingsScope scope) { throw new NotImplementedException(); }
public void NewSettingsScope(string name, string copyFrom = null) { lock (this) { var scope = _database.FirstOrDefault<SettingsScope>("where Name=@0", name); if (scope == null) { scope = new SettingsScope(); scope.Name = name; _database.Save(scope); } if (!TableExists(string.Format("Settings_{0}", scope.ID))) { _database.Execute(string.Format("create table 'Settings_{0}' (Name text, Value text)", scope.ID)); } else { _database.Execute(string.Format("delete from Settings_{0}", scope.ID)); } if (copyFrom != null) { var cscope = _database.FirstOrDefault<SettingsScope>("where Name=@0", copyFrom); if (cscope != null) { _database.Execute(string.Format("insert into Settings_{0} select * from Settings_{1}", scope.ID, cscope.ID)); } List<string> pitl = _database.Fetch<string>(string.Format("SELECT name FROM sqlite_master WHERE type='table' AND name like 'plugin_{0}_%'", cscope.ID)); foreach (var s in pitl) { string orgTable = s; string dstTable = s.Replace(string.Format("plugin_{0}_", cscope.ID), string.Format("plugin_{0}_", scope.ID)); _database.Execute(string.Format("CREATE TABLE {0} AS SELECT * FROM {1} WHERE 0", dstTable, orgTable)); _database.Execute(string.Format("insert into {0} select * from {1}", dstTable, orgTable)); } } } }
/// <summary> /// Initializes and returns a new `UserSettingsProvider` instance. /// </summary> /// <param name="path">The settings menu path.</param> /// <param name="settings">The Settings instance that this provider is inspecting.</param> /// <param name="assemblies">A collection of assemblies to scan for <see cref="UserSettingAttribute"/> and <see cref="UserSettingBlockAttribute"/> attributes.</param> /// <param name="scopes">Which scopes this provider is valid for.</param> /// <exception cref="ArgumentNullException">Thrown if settings or assemblies is null.</exception> public UserSettingsProvider(string path, Settings settings, Assembly[] assemblies, SettingsScope scopes = SettingsScope.User) : base(path, scopes)
public SettingsProvider(string scope) { _currentSettings = new Hashtable(); _scopelessSettings = new Hashtable(); string p = System.IO.Path.Combine(new string[] { System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GAPP" }); if (!Directory.Exists(p)) { Directory.CreateDirectory(p); } string fn = System.IO.Path.Combine(p, "settings.db3"); //create backup first List<string> availableBackups = new List<string>(); if (File.Exists(fn)) { File.Copy(fn, string.Format("{0}.{1}.bak", fn, DateTime.Now.ToString("yyyyMMddHHmmss"))); //keep maximum of X backups availableBackups = Directory.GetFiles(p, "settings.db3.*.bak").OrderBy(x => x).ToList(); while (availableBackups.Count > 20) { File.Delete(availableBackups[0]); availableBackups.RemoveAt(0); } } bool dbOK; bool backupUsed = false; do { try { _database = new PetaPoco.Database(string.Format("data source=file:{0}", fn), Community.CsharpSqlite.SQLiteClient.SqliteClientFactory.Instance); dbOK = _database.ExecuteScalar<string>("PRAGMA integrity_check") == "ok"; //if (availableBackups.Count > 2) dbOK = false; //test } catch { dbOK = false; } if (!dbOK) { backupUsed = true; try { _database.Dispose(); } catch { } _database = null; //delete settings and move to latest File.Delete(fn); if (availableBackups.Count > 0) { File.Move(availableBackups[availableBackups.Count - 1], fn); availableBackups.RemoveAt(availableBackups.Count - 1); } } } while (!dbOK); if (backupUsed) { System.Windows.Forms.MessageBox.Show("The settings file was corrupt and a backup file is restored.", "Settings"); } if (!TableExists("Settings")) { _database.Execute("create table 'Settings' (Name text, Value text)"); _database.Execute("insert into Settings (Name, Value) values ('Scope', 'default')"); } if (!TableExists("SettingsScope")) { _database.Execute("create table 'SettingsScope' (ID integer primary key autoincrement, Name text)"); } if (string.IsNullOrEmpty(scope)) { scope = _database.ExecuteScalar<string>("select Value from Settings where Name=@0", "Scope"); if (string.IsNullOrEmpty(scope)) { scope = "default"; } } _scope = _database.FirstOrDefault<SettingsScope>("where Name=@0", scope); if (_scope == null) { _scope = new SettingsScope(); _scope.Name = scope; _database.Save(_scope); } if (!TableExists(string.Format("Settings_{0}",_scope.ID))) { _database.Execute(string.Format("create table 'Settings_{0}' (Name text, Value text)", _scope.ID)); } var settings = _database.Fetch<Setting>(string.Format("select * from Settings_{0}", _scope.ID)); foreach (var s in settings) { _currentSettings.Add(s.Name, s.Value); } var scopelesssettings = _database.Fetch<Setting>("select * from Settings"); foreach (var s in scopelesssettings) { _scopelessSettings.Add(s.Name, s.Value); } }
XRManagementInstaller(string path, SettingsScope scopes = SettingsScope.Project) : base(path, scopes) { }
public ConsoleColorSettingsProvider(string path, SettingsScope scopes) : base(path, scopes) { }
public override WritableSettingsStore GetWritableSettingsStore(SettingsScope scope) { return(this.StoreFailsToLoad ? null : this.WritableSettingsStore); }
public MyPreferencesProvider(string path, SettingsScope scope) : base(path, scope) { }
public static T Get <T>(string key, SettingsScope scope = SettingsScope.Project, T fallback = default(T)) { return(instance.Get <T>(key, scope, fallback)); }
public AdsSettingsProvider(SettingsScope scopes, IEnumerable <string> keywords = null) : base(GetSettingsPath(), scopes, keywords) { }
public static void Delete <T>(string key, SettingsScope scope = SettingsScope.Project) { instance.DeleteKey <T>(key, scope); }
private DeviceSimulatorProjectSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { }
protected TooltipsSettingsProvider(string path, SettingsScope scope = SettingsScope.Project) : base(path, scope) { }
public XRConfigurationProvider(string path, string buildSettingsKey, Type buildDataType, SettingsScope scopes = SettingsScope.Project) : base(path, scopes) { m_BuildDataType = buildDataType; m_BuildSettingsKey = buildSettingsKey; if (currentSettings == null) { Create(); } }
public Provider(string path, SettingsScope scopes = SettingsScope.User) : base(path, scopes) { }
public ConsoleSettingsProvider(string path, SettingsScope scope = SettingsScope.Project) : base(path, scope) { }
XRSettingsManager(string path, SettingsScope scopes = SettingsScope.Project) : base(path, scopes) { }
MarsPreferencesProvider(string path = "Preferences/MARS", SettingsScope scope = SettingsScope.User) : base(path, scope) { }
/// <summary> /// Provides the <see cref="SettingsStore"/> class for the requested scope which can be used for read-only /// operations. /// </summary> /// <param name="scope">Requested scope.</param> /// <returns><see cref="SettingsStore"/> instance that can be used for accessing the scope.</returns> public override SettingsStore GetReadOnlySettingsStore(SettingsScope scope) { IVsSettingsStore settingsStore; int hr = this.settingsManager.GetReadOnlySettingsStore((uint)scope, out settingsStore); Marshal.ThrowExceptionForHR(hr); return new ShellSettingsStore(settingsStore); }
public DQRBuildSettingsProvider(string path, SettingsScope scope = SettingsScope.Project) : base(path, scope) { }
internal static WritableSettingsStore GetWritableSettingsStore(this SVsServiceProvider vsServiceProvider, SettingsScope scope) { var shellSettingsManager = new ShellSettingsManager(vsServiceProvider); return shellSettingsManager.GetWritableSettingsStore(scope); }
public UnityEventDebuggerSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { Load(); }
public override WritableSettingsStore GetWritableSettingsStore(SettingsScope scope) => _store;
protected override ApplicationSettings GetSettings(SettingsScope scope) { return(_settingsFactory.GetSettings <ArticleSettings>(scope)); }
public override WritableSettingsStore GetWritableSettingsStore(SettingsScope scope) { return this.StoreFailsToLoad ? null : this.WritableSettingsStore; }
/// <summary> /// Gets the read only settings state. /// </summary> /// <param name="scope">The scope.</param> /// <returns>The read only settings state.</returns> public override SettingsStore GetReadOnlySettingsStore(SettingsScope scope) { return new FakeSettingsStore(); }