public string this[string index] { get { if (configuration.ContainsKey(index)) { return(configuration[index]); } else { return(string.Empty); } } set { bool contains = configuration.ContainsKey(index); bool sameValue = configuration[index] == value; if (!contains) { configuration.Add(index, value); } else if (!sameValue) { configuration[index] = value; } if (!contains || !sameValue) { OnConfigChanged?.Invoke(index, value); } } }
/// <summary> /// Changes the current configuration with the specified <paramref name="name"/> /// and/or <paramref name="address"/>, and raises an event to notify of the change. /// </summary> /// <param name="name"> /// [Optional] The new name as which to try reaching the device. /// </param> /// <param name="address"> /// [Optional] The new address at which the device can be reached. /// </param> public void ChangeConfig(string name = null, string address = null) { var config = _config.With(name, address); _config = config; OnConfigChanged?.Invoke(this, config); }
public void HandleConfigChanged() { // Do not verify if change occurred as this function is going to be called again in that case // Do not verify the config in case the bot token has been changed, as the client will be restarted and that will trigger verification bool tokenChanged = Data.BotToken != _prevConfig.BotToken; bool correctionMade = !Save(); BuildChanneLinkList(); if (tokenChanged) { OnTokenChanged?.Invoke(this, EventArgs.Empty); return; // The token changing will trigger a reset } if (!correctionMade) // If a correction was made, this function will be called again { VerifyConfig(); // This function executes on the GUI thread and therefore async calls will trigger deadlocks. // We execute the callbacks on a separate joined thread to avoid these deadlocks. SystemUtil.SynchronousThreadExecute(() => { OnConfigChanged?.Invoke(this, EventArgs.Empty); }); } }
public void Config(XmlElement xmlElement) { if (OnConfigChanged != null) { var breaks = GetConfigFromXml(xmlElement); OnConfigChanged.Invoke(breaks); } }
private void _watcher_Changed(object sender, FileSystemEventArgs e) { if (!_saving || _saveTriggersConfigChangedEvent) { Load(); OnConfigChanged?.Invoke((T)this); } }
public void Config(XmlElement xmlElement) { if (OnConfigChanged != null) { var containers = GetConfigFromXml(xmlElement); OnConfigChanged.Invoke(containers); } }
/// <summary> /// 配置变更事件。 /// </summary> /// <param name="state">状态。</param> private void ConfigChanged(object state) { _cache.Clear(); OnConfigChanged?.Invoke(state); _callbackRegistration?.Dispose(); _callbackRegistration = _config.GetReloadToken() .RegisterChangeCallback(ConfigChanged, state); }
private void UpdateLeapConfig() { leapConfig.OffsetX = LeapOffsetXBar.Value * ConfigValuePrecision; leapConfig.OffsetY = LeapOffsetYBar.Value * ConfigValuePrecision; leapConfig.OffsetZ = LeapOffsetZBar.Value * ConfigValuePrecision; leapConfig.Scale = LeapScaleBar.Value * ConfigValuePrecision; if (OnConfigChanged != null) { OnConfigChanged.Invoke(this, new SerializationEventArgs(LeapHmdConfig.DataIndex, SerializationUtil.Serialize(leapConfig))); } }
public void Fill(Stream stream) { CacheItemParams = "_____Cache_Item_Params_____"; ReReleaseHeader = "_____Re_Release_Header_____"; ClientCachedTime = 365 * 24 * 3600; var content = ""; using (StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8)) { content = sr.ReadToEnd(); } if (string.IsNullOrEmpty(content)) { return; } Snail.Data.Serializer.JsonPopulateObject(content, this); OnConfigChanged?.Invoke(this, null); }
public static void OnConfigChange(bool shouldSetHasConfigChanged = true) { OnConfigChanged?.DelegateSafeInvoke(); hasConfigChanged = shouldSetHasConfigChanged; }
public static void SetConfig(BuilderConfig newBuilderConfig) { config = newBuilderConfig; OnConfigChanged?.Invoke(config); }
internal static void InvokeConfigChanged() { OnConfigChanged?.Invoke(); }
public void ApplyChanges() { OnConfigChanged?.Invoke(); SaveConfig(); }
public static void OnConfigChange() { OnConfigChanged?.Invoke(); }
protected void FireConfigChanged() { OnConfigChanged?.Invoke(); }
public virtual void Changed() { OnConfigChanged?.Invoke(); }
extern public static int BS2_SetNotificationListener(IntPtr context, OnAlarmFired cbOnAlarmFired, OnInputDetected cbOnInputDetected, OnConfigChanged cbOnConfigChanged);