Ejemplo n.º 1
0
        /// <summary>
        /// Remove a particular pair of path with a type from the table.
        /// </summary>
        /// <param name="source">Source of propagation</param>
        /// <param name="dest">Destination of propagation</param>
        /// <param name="type">Type of table</param>
        /// <returns>The PathPair removed.</returns>
        public PathPair RemovePathPair(string source, string dest, TableType type)
        {
            PathPair returnPair = null;
            List<PathPair> usedTable = null;
            //Use different table based on type.
            switch (type)
            {
                case TableType.Create: usedTable = _createEventPathPair; break;
                case TableType.Update: usedTable = _updateEventPathPair; break;
                case TableType.Rename: usedTable = _renameEventPathPair; break;
                case TableType.Delete: usedTable = _deleteEventPathPair; break;

            }
            if (usedTable == null)
            {
                return null;
            }
            lock (this)
            {
                //Create a Copy of the Pathpair, 
                //Find a same PathPair and return it.
                PathPair pathPair = new PathPair(source, dest);
                foreach (PathPair pair in usedTable)
                {
                    if (pathPair.Equals(pair))
                    {
                        returnPair = pair;
                    }
                }
                usedTable.Remove(returnPair);
            }

            return returnPair;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Check if the PathTable contain a particular pair.
 /// </summary>
 /// <param name="pair">The pair to check</param>
 /// <param name="type">The type of table to check</param>
 /// <returns>true if the PathTable contains the pair, false if the PathTable does not contain the pair</returns>
 public bool Contains(PathPair pair, TableType type)
 {
     List<PathPair> usedTable = null;
     switch (type)
     {
         case TableType.Create: usedTable = _createEventPathPair; break;
         case TableType.Update: usedTable = _updateEventPathPair; break;
         case TableType.Rename: usedTable = _renameEventPathPair; break;
         case TableType.Delete: usedTable = _deleteEventPathPair; break;
     }
     if (usedTable == null)
     {
         return false;
     }
     return usedTable.Contains(pair);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Compare if 2 PathPair is Equals
 /// </summary>
 /// <param name="pair">The path pair to compare to</param>
 /// <returns>true if the 2 path pair is equal, otherwise false. PathPair are considered Equal if they contain the same Source and Dest
 /// </returns>
 public bool Equals(PathPair pair)
 {
     if (Dest != pair.Dest) return false;
     if (Source != pair.Source) return false;
     return true;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a new PathPair
        /// </summary>
        /// <param name="source">Source of propagation</param>
        /// <param name="dest">Destination of propagation</param>
        /// <param name="type">Type of table</param>
        /// <returns>true if the pair is added, false if the pair isn't</returns>
        public bool AddPathPair(string source, string dest, TableType type)
        {
            List<PathPair> usedTable = null;
            //Use the table based on the table type.
            switch (type)
            {
                case TableType.Create: usedTable = _createEventPathPair; break;
                case TableType.Update: usedTable = _updateEventPathPair; break;
                case TableType.Rename: usedTable = _renameEventPathPair; break;
                case TableType.Delete: usedTable = _deleteEventPathPair; break;

            }
            if (usedTable == null)
            {
                return false;
            }
            lock (this)
            {
                //Check if the table already contain such a pair.
                PathPair pathPair = new PathPair(source, dest);
                if (!Contains(pathPair, type))
                {
                    usedTable.Add(pathPair);
                    return true;
                }

            }
            return false;
        }