コード例 #1
0
        public virtual bool BeginEdit()
        {
            try
            {
                if (!_isBeingEdited)
                {
                    /// Raise BeforeEdit event and provide a means of cancellation
                    XmlConfigurationElementCancelEventArgs e = new XmlConfigurationElementCancelEventArgs(this, false);
                    this.OnBeforeEdit(this, e);
                    if (e.Cancel)
                    {
                        return(false);
                    }

                    /// place the element in edit mode and clone ourself so that future changes will be redirected to the clone and not to ourself
                    _editableProxy = this.GetElementToEdit();
                    if (_editableProxy != null)
                    {
                        _editableProxy.Changed         += new XmlConfigurationElementEventHandler(this.OnChanged);
                        _editableProxy._isEditableProxy = true;
                        _isBeingEdited = true;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(false);
        }
コード例 #2
0
        public static string DescribeElementEnteringEdit(XmlConfigurationElementCancelEventArgs e)
        {
            try
            {
                string elementType = null;
                XmlConfigurationElementTypes et = e.Element.GetElementType();
                switch (et)
                {
                case XmlConfigurationElementTypes.XmlConfiguration:                             elementType = "configuration"; break;

                case XmlConfigurationElementTypes.XmlConfigurationCategory:             elementType = "category"; break;

                case XmlConfigurationElementTypes.XmlConfigurationElement:              elementType = "element"; break;

                case XmlConfigurationElementTypes.XmlConfigurationOption:               elementType = "option"; break;
                }
                ;

                return(string.Format("The {0} '{1}' is entering edit mode at {2} on {3}. The current user is {4}.", elementType, e.Element.Fullpath, DateTime.Now.ToLongTimeString(), DateTime.Now.ToLongDateString(), System.Environment.UserName));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            return(null);
        }
コード例 #3
0
        public void OnBeforeEdit(object sender, XmlConfigurationElementCancelEventArgs e)
        {
            try
            {
                //EventTracing.TraceMethodAndDelegate(this, this.BeforeEdit);

                if (this.BeforeEdit != null)
                {
                    this.BeforeEdit(sender, e);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
		public void OnBeforeEdit(object sender, XmlConfigurationElementCancelEventArgs e)
		{
			try
			{
				//EventTracing.TraceMethodAndDelegate(this, this.BeforeEdit);

				if (this.BeforeEdit != null)
					this.BeforeEdit(sender, e);
			}
			catch(Exception ex)
			{
				Debug.WriteLine(ex);
			}
		}
コード例 #5
0
		public virtual bool BeginEdit()
		{
			try
			{
				if (!_isBeingEdited)
				{
					/// Raise BeforeEdit event and provide a means of cancellation
					XmlConfigurationElementCancelEventArgs e = new XmlConfigurationElementCancelEventArgs(this, false);
					this.OnBeforeEdit(this, e);
					if (e.Cancel)
						return false;
					
					/// place the element in edit mode and clone ourself so that future changes will be redirected to the clone and not to ourself					
					_editableProxy = this.GetElementToEdit();		
					if (_editableProxy != null)
					{
						_editableProxy.Changed += new XmlConfigurationElementEventHandler(this.OnChanged);
						_editableProxy._isEditableProxy = true;
						_isBeingEdited = true;
						return true;
					}					
				}
			}
			catch(Exception ex)
			{
				Debug.WriteLine(ex);
			}
			return false;
		}