SetPropertyPersistence() public method

public SetPropertyPersistence ( string name, bool doPersist ) : void
name string
doPersist bool
return void
Ejemplo n.º 1
0
        /// <summary>
        /// set the value of a property to a node of a list. Also sets the corresponding parameters property.
        /// </summary>
        /// <remarks> this is static so that it can be called by the XCore initializationcode and set from the contents of the XML configuration file</remarks>
        /// <param name="mediator"></param>
        /// <param name="propertyTable"></param>
        /// <param name="choiceValue"></param>
        /// <param name="choiceParameters"></param>
        /// <param name="propertyName"></param>
        /// <param name="settingsGroup"></param>
        static public void ChooseSinglePropertyAtomicValue(Mediator mediator, PropertyTable propertyTable, string choiceValue,
                                                           XmlNode choiceParameters, string propertyName, PropertyTable.SettingsGroup settingsGroup)
        {
            //a hack (that may be we could live with)
            //	if(choiceParameters !=null)
            //	{
            propertyTable.SetProperty(propertyName + "Parameters", choiceParameters, settingsGroup, true);
            //it is possible that we would like to persist these parameters
            //however, as a practical matter, you cannot have XmlNodes witch do not belong to a document.
            //therefore, they could not be deserialize if we did save them.
            //unless, of course, we convert them to a string before serializing.
            //However, when de-serializing, what document would we attach the new xmlnode to?
            propertyTable.SetPropertyPersistence(propertyName + "Parameters", false, settingsGroup);
            //}


            //remember, each of these calls to SetProperty() generate a broadcast, so the order of these two calls
            //is relevant.
            propertyTable.SetProperty(propertyName, choiceValue, settingsGroup, true);

            if (choiceParameters != null)
            {
                //since we cannot persist the parameters, it's safer to not persist the choice either.
                propertyTable.SetPropertyPersistence(propertyName, false, settingsGroup);
            }
        }
Ejemplo n.º 2
0
        static public void ChooseSinglePropertySequenceValue(Mediator mediator, PropertyTable propertyTable, string choiceValue,
                                                             XmlNode choiceParameterNode, string propertyName, bool fEmptyAllowed, PropertyTable.SettingsGroup settingsGroup)
        {
            propertyTable.SetProperty(propertyName + "Parameters", choiceParameterNode, settingsGroup, true);
            propertyTable.SetPropertyPersistence(propertyName + "Parameters", false, settingsGroup);
            string sValue = propertyTable.GetStringProperty(propertyName, "", settingsGroup);

            string[] rgsValues = sValue.Split(',');
            int      idx       = -1;

            if (sValue == choiceValue)
            {
                if (fEmptyAllowed)
                {
                    sValue = "";
                }
            }
            else if ((idx = IndexOf(rgsValues, choiceValue)) != -1)
            {
                // remove the choiceValue from the string.
                Debug.Assert(rgsValues.Length > 1);
                System.Text.StringBuilder sbValues = new System.Text.StringBuilder(sValue.Length);
                for (int i = 0; i < rgsValues.Length; ++i)
                {
                    if (idx != i)
                    {
                        if (sbValues.Length > 0)
                        {
                            sbValues.Append(",");
                        }
                        sbValues.Append(rgsValues[i]);
                    }
                }
                sValue = sbValues.ToString();
            }
            else
            {
                if (sValue.Length == 0)
                {
                    sValue = choiceValue;
                }
                else
                {
                    sValue = sValue + "," + choiceValue;
                }
            }
            propertyTable.SetProperty(propertyName, sValue, settingsGroup, true);
            propertyTable.SetPropertyPersistence(propertyName, false, settingsGroup);
        }
Ejemplo n.º 3
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK != openFileDialog1.ShowDialog())
            {
                return;
            }

            tbPath.Text = openFileDialog1.FileName;
            UpdateButtons();
            if (btnOK.Enabled)
            {
                m_propertyTable.SetProperty(FilePropertyName, tbPath.Text, true);
                m_propertyTable.SetPropertyPersistence(FilePropertyName, true);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_mediator != null)
                {
                    m_mediator.RemoveColleague(this);
                    m_propertyTable.SetProperty("ContextHelper", null, false);
                    m_propertyTable.SetPropertyPersistence("ContextHelper", false);
                }
                if (m_helpIdToElt != null)
                {
                    m_helpIdToElt.Clear();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_mediator    = null;
            m_helpIdToElt = null;
            m_document    = null;

            m_isDisposed = true;
        }
Ejemplo n.º 5
0
        /// <summary/>
        public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters)
        {
            CheckDisposed();
            m_mediator      = mediator;
            m_propertyTable = propertyTable;
            mediator.AddColleague(this);
            m_propertyTable.SetProperty("ContextHelper", this, false);
            m_propertyTable.SetPropertyPersistence("ContextHelper", false);

            ParentControl = m_propertyTable.GetValue <Control>("window");
            m_document    = new XmlDocument();

            //we use the  directory of the file which held are parameters as the starting point
            //of the path we were given.
            string path = XmlUtils.GetMandatoryAttributeValue(configurationParameters,
                                                              "contextHelpPath");
            var configParamatersBasePath = FileUtils.StripFilePrefix(configurationParameters.BaseURI);

            path = Path.Combine(Path.GetDirectoryName(configParamatersBasePath), path);
            m_document.Load(path);
            //m_items = m_document.SelectNodes("strings/item");

            ShowAlways = m_propertyTable.GetBoolProperty("ShowBalloonHelp", true);
        }