Exemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            Tag        newTag  = new Tag(tagListFull[textBox4.Text], textBox5.Text);
            TagFactory factory = TagFactory.getInstance();

            factory.writeTag(textBox3.Text, newTag);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Changes the datatype of an existing TagType object, and calls TagFactory
        /// to make the change to the reference file.
        ///
        /// Any existing tags will remain, however their values will be set to the
        /// default minimum.
        /// </summary>
        /// <param name="name">The name of the TagType to be modified.</param>
        /// <param name="newDataType">The new datatype of the TagType to be modified.</param>
        public void changeTagType(string name, int newDataType)
        {
            object clearValue;

            switch (newDataType)
            {
            case Constants.DATATYPE_DATE:
                clearValue = DateTime.MinValue;
                break;

            case Constants.DATATYPE_INT:
                clearValue = int.MinValue;
                break;

            case Constants.DATATYPE_STRING:
                clearValue = "";
                break;

            default:
                clearValue = "";
                break;
            }

            if (tagTypeList.ContainsKey(name))
            {
                tagTypeList[name].dataType = newDataType;
                foreach (KeyValuePair <string, Dictionary <string, Tag> > kvp in tagList)
                {
                    if (kvp.Value.ContainsKey(name))
                    {
                        kvp.Value[name].tagValue = clearValue;
                        tagFactory.writeTag(kvp.Key, kvp.Value[name]);
                    }
                }

                tagFactory.writeTagType(tagTypeList[name]);
            }
        }