Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        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);
                });
            }
        }
Ejemplo n.º 4
0
 public void Config(XmlElement xmlElement)
 {
     if (OnConfigChanged != null)
     {
         var breaks = GetConfigFromXml(xmlElement);
         OnConfigChanged.Invoke(breaks);
     }
 }
Ejemplo n.º 5
0
 private void _watcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (!_saving || _saveTriggersConfigChangedEvent)
     {
         Load();
         OnConfigChanged?.Invoke((T)this);
     }
 }
Ejemplo n.º 6
0
 public void Config(XmlElement xmlElement)
 {
     if (OnConfigChanged != null)
     {
         var containers = GetConfigFromXml(xmlElement);
         OnConfigChanged.Invoke(containers);
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 配置变更事件。
        /// </summary>
        /// <param name="state">状态。</param>
        private void ConfigChanged(object state)
        {
            _cache.Clear();

            OnConfigChanged?.Invoke(state);
            _callbackRegistration?.Dispose();

            _callbackRegistration = _config.GetReloadToken()
                                    .RegisterChangeCallback(ConfigChanged, state);
        }
Ejemplo n.º 8
0
 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)));
     }
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public static void OnConfigChange(bool shouldSetHasConfigChanged = true)
 {
     OnConfigChanged?.DelegateSafeInvoke();
     hasConfigChanged = shouldSetHasConfigChanged;
 }
Ejemplo n.º 11
0
 public static void SetConfig(BuilderConfig newBuilderConfig)
 {
     config = newBuilderConfig;
     OnConfigChanged?.Invoke(config);
 }
Ejemplo n.º 12
0
 internal static void InvokeConfigChanged()
 {
     OnConfigChanged?.Invoke();
 }
Ejemplo n.º 13
0
 public void ApplyChanges()
 {
     OnConfigChanged?.Invoke();
     SaveConfig();
 }
Ejemplo n.º 14
0
 public static void OnConfigChange()
 {
     OnConfigChanged?.Invoke();
 }
Ejemplo n.º 15
0
 protected void FireConfigChanged()
 {
     OnConfigChanged?.Invoke();
 }
Ejemplo n.º 16
0
 public virtual void Changed()
 {
     OnConfigChanged?.Invoke();
 }
Ejemplo n.º 17
0
 extern public static int BS2_SetNotificationListener(IntPtr context, OnAlarmFired cbOnAlarmFired, OnInputDetected cbOnInputDetected, OnConfigChanged cbOnConfigChanged);