Exemplo n.º 1
0
 /// <summary>
 /// Merge data object with this list.
 /// Only objects that are not already in the list
 /// are added to the list.
 /// </summary>
 /// <param name='data'>The data to merge.</param>
 public void Merge(DataId data)
 {
     if (data.IsNotNull() && !Exists(data))
     {
         Add(data);
     }
 }
 /// <summary>
 /// Test if two DataId references are equal.
 /// </summary>
 /// <param name='data1'>Data to compare.</param>
 /// <param name='data2'>Data to compare.</param>
 /// <returns>True if both references are null or
 /// if they have the same type and Id.</returns>
 public static Boolean AreEqual(DataId data1, DataId data2)
 {
     if (data1.IsNull() && data2.IsNull())
     {
         return(true);
     }
     if (data1.IsNull() || data2.IsNull())
     {
         return(false);
     }
     if (data1.GetType() != data2.GetType())
     {
         return(false);
     }
     return(data1.Id == data2.Id);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Checks if data is in the list.
        /// </summary>
        /// <param name='dataId'>Object to be checked.</param>
        /// <returns>Boolean value indicating if the data exists in the list or not.</returns>
        public Boolean Exists(DataId dataId)
        {
            Object value;

            if (_optimize)
            {
                value = _idHashTable[dataId.Id];
                return((value != null) && (value is DataId));
            }
            else
            {
                foreach (DataId dataIdInList in this)
                {
                    if (dataIdInList.Id == dataId.Id)
                    {
                        // Data found.
                        return(true);
                    }
                }

                // Data not found.
                return(false);
            }
        }
 /// <summary>
 /// Test if two DataId references are not equal.
 /// </summary>
 /// <param name='data1'>Data to compare.</param>
 /// <param name='data2'>Data to compare.</param>
 /// <returns>False if both references are null or
 /// if they have the same type and Id.</returns>
 public static Boolean AreNotEqual(DataId data1, DataId data2)
 {
     return(!AreEqual(data1, data2));
 }