Example #1
0
        /// <summary>
        /// Removes the item at the specified index
        /// from the dictionary.
        /// </summary>
        /// <param name="index">The index of the item in the list.</param>
        /// <param name="value">The value of the item at the specified index.</param>
        protected override void OnRemoveComplete(int index, object value)
        {
            NameValueItem item = (NameValueItem)value;

            this.RemoveItem(item);
            item.Owner = null;
            base.OnRemoveComplete(index, value);
        }
        public void CustomPropertiesTest()
        {
            NameValueItem testItem = new NameValueItem("TEST", "VALUE");

            CustomDistributionStrategyData data = new CustomDistributionStrategyData();
            data.Attributes.Add(testItem);

            Assert.AreEqual(testItem, data.Attributes[0]);
        }
Example #3
0
        private void RemoveItem(NameValueItem olditem)
        {
            olditem.Owner = null;
            int oldIndex = this.dictionary.IndexOfValue(olditem);

            if (oldIndex >= 0)
            {
                this.dictionary.RemoveAt(oldIndex);
            }
        }
Example #4
0
        /// <summary>
        /// Inserts the specified item into the dictionary.
        /// </summary>
        /// <param name="index">The index of the item in the list.</param>
        /// <param name="value">The value of the item to add to the list.</param>
        protected override void OnInsertComplete(int index, object value)
        {
            base.OnInsertComplete(index, value);
            NameValueItem item = (NameValueItem)value;

            item.Owner = this;
            if ((item.Name != null) && (item.Name.Length != 0))
            {
                this.dictionary.Add(item.Name, item);
            }
        }
Example #5
0
        /// <summary>
        /// Removes the entry with the specified <paramref name="name"/> from the collection.
        /// </summary>
        /// <param name="name">
        /// <para>The name of the item to remove.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        public void Remove(string name)
        {
            ArgumentValidation.CheckForNullReference(name, "name");

            NameValueItem item = (NameValueItem)this.dictionary[name];

            if (item != null)
            {
                this.List.RemoveAt(this.List.IndexOf(item));
            }
        }
Example #6
0
        internal void Set(NameValueItem item)
        {
            int index = this.List.IndexOf(item);

            if (index >= 0)
            {
                this[index] = item;
            }
            else
            {
                this.Add(item);
            }
        }
Example #7
0
        /// <summary>
        /// Updates the value dictionary with the new value.
        /// </summary>
        /// <param name="index">The index of the item in the list.</param>
        /// <param name="oldValue">The old value that is being replaced.</param>
        /// <param name="newValue">The new value that is being set.</param>
        protected override void OnSetComplete(int index, object oldValue, object newValue)
        {
            base.OnSetComplete(index, oldValue, newValue);
            if (oldValue != null)
            {
                NameValueItem olditem = (NameValueItem)oldValue;
                this.RemoveItem(olditem);
            }
            NameValueItem newitem = (NameValueItem)newValue;

            newitem.Owner = this;
            this.dictionary[newitem.Name] = newValue;
        }
Example #8
0
 /// <summary>
 /// <para>Gets or sets the <see cref="NameValueItem"/> associated with the specified <paramref name="name"/>.</para>
 /// </summary>
 /// <param name="name">
 /// <para>The name of the <see cref="NameValueItem"/> value to get.</para>
 /// </param>
 /// <value>
 /// <para>The value associated with the specified <paramref name="name"/>. If the specified <paramref name="name"/> is not found, attempting to get it returns a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </value>
 public string this[string name]
 {
     get
     {
         NameValueItem item = (NameValueItem)this.dictionary[name];
         if (item != null)
         {
             return(item.Value);
         }
         else
         {
             return(null);
         }
     }
 }
        public void CustomStrategyNodeTest()
        {
            NameValueItem item = new NameValueItem("TeST", "VALUE");
            string name = "testName";
            string type = "fakeType";

            CustomDistributionStrategyNode node = new CustomDistributionStrategyNode();
            applicationNode.Nodes.Add(node);
            node.Name = name;
            node.TypeName = type;
            node.Attributes.Add(item);

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.TypeName);
            Assert.AreEqual(item, node.Attributes[0]);
        }
        public void CustomFormatterNodeTest()
        {
            NameValueItem testItem = new NameValueItem("TEST", "VALUE");
            string name = "testName";
            string type = "testType";

            CustomFormatterNode node = new CustomFormatterNode();
            GeneratedApplicationNode.Nodes.Add(node);
            node.Name = name;
            node.TypeName = type;
            node.Attributes.Add(testItem);

            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.TypeName);
            Assert.AreEqual(testItem, node.Attributes[0]);
            Assert.AreEqual(1, node.Attributes.Count);
        }
        public void CustomFormatterDataTest()
        {
            NameValueItem testItem = new NameValueItem("TEST", "VALUE");
            string name = "testName";
            string type = "testType";

            CustomFormatterData data = new CustomFormatterData();
            data.Attributes.Add(testItem);
            data.TypeName = type;
            data.Name = name;

            CustomFormatterNode node = new CustomFormatterNode(data);
            GeneratedApplicationNode.Nodes.Add(node);
            CustomFormatterData nodeData = (CustomFormatterData) node.FormatterData;

            Assert.AreEqual(testItem, nodeData.Attributes[0]);
            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(type, nodeData.TypeName);
        }
 /// <summary>
 /// <para>Inserts an element into the <see cref="NameValueItemCollection"/> at the specified index.</para>
 /// </summary>
 /// <param name="index">
 /// <para>The zero-based index at which value should be inserted.</para>
 /// </param>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to insert.</para>
 /// </param>
 /// <exception name="ArgumentOutOfRangeException">
 /// <para><paramref name="index"/> is less than zero.</para>
 /// <para>- or -</para>
 /// <para><paramref name="index"/> is greater than <seealso cref="CollectionBase.Count"/>.</para>
 /// </exception>
 public void Insert(int index, NameValueItem item)
 {
     this.List.Insert(index, item);
 }
 /// <summary>
 /// <para>Searches for the specified <see cref="NameValueItem"/> and returns the zero-based index of the first occurrence within the entire <see cref="NameValueItemCollection"/>.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to locate in the <see cref="NameValueItemCollection"/>.</para>
 /// </param>
 /// <returns>
 /// <para>The zero-based index of the first occurrence of value within the entire <see cref="NameValueItemCollection"/>, if found; otherwise, -1.</para>
 /// </returns>
 public int IndexOf(NameValueItem item)
 {
     return List.IndexOf(item);
 }
 /// <summary>
 /// Copies the entire NameValueItem list to a 
 /// compatible one-dimensional array of NameValueItem entries, 
 /// starting at the specified index of the target array.
 /// </summary>
 /// <param name="array">An array of type NameValueItem to which 
 /// the access control list entries will be copied. The array 
 /// must have zero-based indexing. </param>
 /// <param name="index">The index in the array at which to 
 /// begin copying the NameValueItem list entries.</param>
 public void CopyTo(NameValueItem[] array, int index)
 {
     this.List.CopyTo(array, index);
 }
 /// <summary>
 /// <para>Determines whether the <see cref="NameValueItemCollection"/> contains a specific element.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The Object to locate in the <see cref="NameValueItemCollection"/>.</para>
 /// </param>
 /// <returns>
 /// <para><see langword="true"/> if the <see cref="NameValueItemCollection"/> contains the specified value; otherwise, <see langword="false"/></para>
 /// </returns>
 public bool Contains(NameValueItem item)
 {
     return List.Contains(item);
 }
 /// <summary>
 /// <para>Adds an <see cref="NameValueItem"/> into the collection.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to add. The value can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </param>
 /// <remarks>
 /// <para>If a reference already exists in the collection by <seealso cref="XmlIncludeTypeData.Name"/>, it will be replaced with the new reference.</para>
 /// </remarks>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="item"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// <para>- or -</para>
 /// <para><seealso cref="NameValueItem.Name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </exception>
 public void Add(NameValueItem item)
 {
     this.List.Add(item);
 }
Example #17
0
 /// <summary>
 /// <para>Searches for the specified <see cref="NameValueItem"/> and returns the zero-based index of the first occurrence within the entire <see cref="NameValueItemCollection"/>.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to locate in the <see cref="NameValueItemCollection"/>.</para>
 /// </param>
 /// <returns>
 /// <para>The zero-based index of the first occurrence of value within the entire <see cref="NameValueItemCollection"/>, if found; otherwise, -1.</para>
 /// </returns>
 public int IndexOf(NameValueItem item)
 {
     return(List.IndexOf(item));
 }
 internal void Set(NameValueItem item)
 {
     int index = this.List.IndexOf(item);
     if (index >= 0)
     {
         this[index] = item;
     }
     else
     {
         this.Add(item);
     }
 }
Example #19
0
 /// <summary>
 /// <para>Determines whether the <see cref="NameValueItemCollection"/> contains a specific element.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The Object to locate in the <see cref="NameValueItemCollection"/>.</para>
 /// </param>
 /// <returns>
 /// <para><see langword="true"/> if the <see cref="NameValueItemCollection"/> contains the specified value; otherwise, <see langword="false"/></para>
 /// </returns>
 public bool Contains(NameValueItem item)
 {
     return(List.Contains(item));
 }
Example #20
0
 /// <summary>
 /// <para>Adds an <see cref="NameValueItem"/> into the collection.</para>
 /// </summary>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to add. The value can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </param>
 /// <remarks>
 /// <para>If a reference already exists in the collection by <seealso cref="XmlIncludeTypeData.Name"/>, it will be replaced with the new reference.</para>
 /// </remarks>
 /// <exception cref="ArgumentNullException">
 /// <para><paramref name="item"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// <para>- or -</para>
 /// <para><seealso cref="NameValueItem.Name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
 /// </exception>
 public void Add(NameValueItem item)
 {
     this.List.Add(item);
 }
 private void RemoveItem(NameValueItem olditem)
 {
     olditem.Owner = null;
     int oldIndex = this.dictionary.IndexOfValue(olditem);
     if (oldIndex >= 0)
     {
         this.dictionary.RemoveAt(oldIndex);
     }
 }
Example #22
0
 /// <summary>
 /// <para>Inserts an element into the <see cref="NameValueItemCollection"/> at the specified index.</para>
 /// </summary>
 /// <param name="index">
 /// <para>The zero-based index at which value should be inserted.</para>
 /// </param>
 /// <param name="item">
 /// <para>The <see cref="NameValueItem"/> to insert.</para>
 /// </param>
 /// <exception name="ArgumentOutOfRangeException">
 /// <para><paramref name="index"/> is less than zero.</para>
 /// <para>- or -</para>
 /// <para><paramref name="index"/> is greater than <seealso cref="CollectionBase.Count"/>.</para>
 /// </exception>
 public void Insert(int index, NameValueItem item)
 {
     this.List.Insert(index, item);
 }