public object this[string key]
        {
            get
            {
                lock (lockProps)
                {
                    PopulateProperties();
                    if (!knownProps.ContainsKey(key.ToUpper()))
                    {
                        return(null);
                    }
                    return(knownProps[key.ToUpper()].GetValue(this, null));
                }
            }
            set
            {
                lock (lockProps)
                {
                    PopulateProperties();
                    if (!knownProps.ContainsKey(key.ToUpper()))
                    {
                        return;
                    }

                    if (PropertySet != null)
                    {
                        PropertyDelegateEventArgs arg = new PropertyDelegateEventArgs {
                            Property = key.ToUpper(), OldValue = this[key.ToUpper()], NewValue = value, CancelEvent = false
                        };
                        PropertySet(this, arg);
                        if (arg.CancelEvent == true)
                        {
                            IsDirty = true;
                            return;
                        }
                    }

                    if (knownProps[key.ToUpper()].PropertyType.IsArray)
                    {
                        int nb = Math.Min(((Array)knownProps[key.ToUpper()].GetValue(this, null)).Length, ((Array)value).Length);
                        for (int i = 0; i < nb; i++)
                        {
                            SetArrayValue(key, i, value);
                        }

                        /*for (int i = 0; i < nb; i++)
                         *  knownProps[key.ToUpper()].SetValue(this, value, new object[] { i });*/
                    }
                    else
                    {
                        knownProps[key.ToUpper()].SetValue(this, value, null);
                    }
                }
            }
        }
 /// <summary>
 /// Calls the PropertySet call back.
 /// If cancelled then return false, otherwise return true.
 /// </summary>
 /// <param name="evt"></param>
 /// <returns></returns>
 internal bool CallPropertySet(PropertyDelegateEventArgs evt)
 {
     if (PropertySet != null)
     {
         PropertySet(this, evt);
         if (evt.CancelEvent == true)
         {
             IsDirty = true;
             return(false);
         }
     }
     return(true);
 }
 /// <summary>
 /// Calls the PropertySet call back.
 /// If cancelled then return false, otherwise return true.
 /// </summary>
 /// <param name="evt"></param>
 /// <returns></returns>
 internal bool CallPropertySet(PropertyDelegateEventArgs evt)
 {
     if (PropertySet != null)
     {
         PropertySet(this, evt);
         if (evt.CancelEvent == true)
         {
             IsDirty = true;
             return false;
         }
     }
     return true;
 }
 void channelRestartGateway_PropertySet(object sender, PropertyDelegateEventArgs e)
 {
     if ((int)e.NewValue == 1)
     {
         e.CancelEvent = true;
         gateway.StopGateway();
         Thread.Sleep(2000);
         gateway.LoadConfig();
         gateway.StartGateway();
     }
     else if ((int)e.NewValue == 2)
     {
         e.CancelEvent = true;
         gateway.StopGateway();
         TcpManager.DisposeAll();
         Thread.Sleep(2000);
         gateway.LoadConfig();
         gateway.StartGateway();
     }
 }
        public object this[string key]
        {
            get
            {
                lock (lockProps)
                {
                    PopulateProperties();
                    if (!knownProps.ContainsKey(key.ToUpper()))
                        return null;
                    return knownProps[key.ToUpper()].GetValue(this, null);
                }
            }
            set
            {
                lock (lockProps)
                {
                    PopulateProperties();
                    if (!knownProps.ContainsKey(key.ToUpper()))
                        return;

                    if (PropertySet != null)
                    {
                        PropertyDelegateEventArgs arg = new PropertyDelegateEventArgs { Property = key.ToUpper(), OldValue = this[key.ToUpper()], NewValue = value, CancelEvent = false };
                        PropertySet(this,arg );
                        if (arg.CancelEvent == true)
                        {
                            IsDirty = true;
                            return;
                        }
                    }

                    if (knownProps[key.ToUpper()].PropertyType.IsArray)
                    {
                        int nb = Math.Min(((Array)knownProps[key.ToUpper()].GetValue(this, null)).Length, ((Array)value).Length);
                        for (int i = 0; i < nb; i++)
                            SetArrayValue(key, i, value);
                        /*for (int i = 0; i < nb; i++)
                            knownProps[key.ToUpper()].SetValue(this, value, new object[] { i });*/
                    }
                    else
                        knownProps[key.ToUpper()].SetValue(this, value, null);
                }
            }
        }