Beispiel #1
0
        /// <summary>
        /// Makes a deep copy of the current DbContentCatalog.
        /// </summary>
        /// <returns> A new DbContentCatalog object reflecting the cloned DbContentCatalog object.</returns>
        public DbContentCatalog Copy()
        {
            DbContentCatalog dbContentCatalog = new DbContentCatalog();

            CopyTo(dbContentCatalog);
            return(dbContentCatalog);
        }
Beispiel #2
0
        /// <summary>
        /// Makes a deep copy of the current DbContentCatalog.
        /// </summary>
        /// <returns> A new DbContentCatalog object reflecting the cloned DbContentCatalog object.</returns>
        /// <param name="isolation">Placeholders are used to isolate the DbContentCatalog from its children.</param>
        public DbContentCatalog Copy(bool isolation)
        {
            DbContentCatalog dbContentCatalog = new DbContentCatalog();

            CopyTo(dbContentCatalog, isolation);
            return(dbContentCatalog);
        }
Beispiel #3
0
        /// <summary>
        /// Duplicates DbContentCatalog object into a database; may or may not be the same database
        /// as the parent object.
        /// </summary>
        /// <returns> A new DbContentCatalog object reflecting the replicated DbContentCatalog object.</returns>
        public DbContentCatalog Duplicate()
        {
            DbContentCatalog clonedDbContentCatalog = this.Clone();

            // Insert must be called after children are replicated!
            clonedDbContentCatalog.iD       = DbContentCatalogManager._insert(clonedDbContentCatalog);
            clonedDbContentCatalog.isSynced = true;
            return(clonedDbContentCatalog);
        }
Beispiel #4
0
        public bool Equals(DbContentCatalog dbContentCatalog)
        {
            if (dbContentCatalog == null)
            {
                return(false);
            }

            return(this.iD == dbContentCatalog.iD);
        }
Beispiel #5
0
        public static DbContentCatalog NewPlaceHolder(int iD)
        {
            DbContentCatalog dbContentCatalog = new DbContentCatalog();

            dbContentCatalog.iD            = iD;
            dbContentCatalog.isPlaceHolder = true;
            dbContentCatalog.isSynced      = true;
            return(dbContentCatalog);
        }
Beispiel #6
0
        public void Remove(DbContentCatalog value)
        {
            OnCollectionChanged(EventArgs.Empty);
            int index = IndexOf(value);

            if (index == -1)
            {
                throw(new Exception("DbContentCatalog not found in collection."));
            }
            RemoveAt(index);
        }
Beispiel #7
0
 public void Add(DbContentCatalog dbContentCatalog, TimeSpan slidingExpiration)
 {
     lock (this)
     {
         count++;
         ensureArrays();
         dbContentCatalogArray[count - 1] = dbContentCatalog;
         timeStamps[count - 1]            = DateTime.Now;
         absoluteExpirations[count - 1]   = DateTime.Now.Add(slidingExpiration); // Never Expires
         slidingExpirations[count - 1]    = slidingExpiration;                   // Never slides
         quickSort(0, count - 1);
     }
 }
Beispiel #8
0
 public int IndexOf(DbContentCatalog value)
 {
     lock (this)
     {
         for (int x = 0; x < count; x++)
         {
             if (DbContentCatalogArray[x].Equals(value))
             {
                 return(x);
             }
         }
         return(-1);
     }
 }
Beispiel #9
0
 /// <summary>
 /// Ensures that the index and object array are sized correctly
 /// for additions. This method should be protected by locks
 /// issued by calling methods.
 /// </summary>
 private void ensureArrays()
 {
     if (count > dbContentCatalogArray.GetUpperBound(0) + 1)
     {
         DbContentCatalog[] tempDbContentCatalogArray = new DbContentCatalog[count * 2];
         DateTime[]         tempTimeStamps            = new DateTime[count * 2];
         DateTime[]         tempAbsoluteExpirations   = new DateTime[count * 2];
         TimeSpan[]         tempSlidingExpirations    = new TimeSpan[count * 2];
         Array.Copy(dbContentCatalogArray, tempDbContentCatalogArray, count - 1);
         Array.Copy(timeStamps, tempTimeStamps, count - 1);
         Array.Copy(absoluteExpirations, tempAbsoluteExpirations, count - 1);
         Array.Copy(slidingExpirations, tempSlidingExpirations, count - 1);
         dbContentCatalogArray = tempDbContentCatalogArray;
         timeStamps            = tempTimeStamps;
         absoluteExpirations   = tempAbsoluteExpirations;
         slidingExpirations    = tempSlidingExpirations;
     }
 }
Beispiel #10
0
 public int Add(DbContentCatalog value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DbContentCatalogArray.GetUpperBound(0) + 1)
         {
             DbContentCatalog[] tempDbContentCatalogArray = new DbContentCatalog[count * 2];
             Array.Copy(DbContentCatalogArray, tempDbContentCatalogArray, count - 1);
             DbContentCatalogArray = tempDbContentCatalogArray;
         }
         DbContentCatalogArray[count - 1] = value;
     }
     return(count - 1);
 }
Beispiel #11
0
        public int Compare(DbContentCatalog a, DbContentCatalog b)
        {
            int result = 0;

            for (int i = 0; i <= _keys.GetUpperBound(0); i++)
            {
                result = 0;

                switch (_keys[i])
                {
                case CatalogCompareKey.Title:
                    result = string.Compare(a.Title, b.Title);
                    break;

                case CatalogCompareKey.MenuOrder:
                    result = a.MenuOrder - b.MenuOrder;
                    break;

                case CatalogCompareKey.MenuEnabled:
                    if (a.MenuEnabled & !b.MenuEnabled)
                    {
                        result = -1;
                    }
                    else if (!a.MenuEnabled & b.MenuEnabled)
                    {
                        result = 1;
                    }
                    break;

                case CatalogCompareKey.SortOrder:
                    result = a.SortOrder - b.SortOrder;
                    break;
                }

                // cease compare processing if the result is not equal
                if (result != 0)
                {
                    return(result);
                }
            }

            return(result);
        }
Beispiel #12
0
 public void Insert(int index, DbContentCatalog value)
 {
     OnCollectionChanged(EventArgs.Empty);
     lock (this)
     {
         count++;
         // Resize the array if the count is greater than the length
         // of the array.
         if (count > DbContentCatalogArray.GetUpperBound(0) + 1)
         {
             DbContentCatalog[] tempDbContentCatalogArray = new DbContentCatalog[count * 2];
             Array.Copy(DbContentCatalogArray, tempDbContentCatalogArray, count - 1);
             DbContentCatalogArray = tempDbContentCatalogArray;
         }
         for (int x = index + 1; x == count - 2; x++)
         {
             DbContentCatalogArray[x] = DbContentCatalogArray[x - 1];
         }
         DbContentCatalogArray[index] = value;
     }
 }
Beispiel #13
0
 public void CheckedAdd(DbContentCatalog dbContentCatalog, TimeSpan slidingExpiration)
 {
     lock (this)
     {
         int i = binarySearch(dbContentCatalog.iD);
         if (i != -1)
         {
             dbContentCatalogArray[i] = dbContentCatalog;
             absoluteExpirations[i]   = DateTime.Now.Add(slidingExpiration); // Expires
             slidingExpirations[i]    = slidingExpiration;                   // Never slides
             return;
         }
         count++;
         ensureArrays();
         dbContentCatalogArray[count - 1] = dbContentCatalog;
         timeStamps[count - 1]            = DateTime.Now;
         absoluteExpirations[count - 1]   = DateTime.Now.Add(slidingExpiration); // Expires
         slidingExpirations[count - 1]    = slidingExpiration;                   // Never slides
         quickSort(0, count - 1);
     }
 }
Beispiel #14
0
 public bool Contains(DbContentCatalog value)
 {
     return(IndexOf(value) != -1);
 }
Beispiel #15
0
 /// <summary>
 /// Compares the object's ID to another object's ID.
 /// </summary>
 public int CompareTo(DbContentCatalog dbContentCatalog)
 {
     return(this.iD - dbContentCatalog.iD);
 }
Beispiel #16
0
        /// <summary>
        /// Compares the object's ID to another object's ID.
        /// </summary>
        int IComparable.CompareTo(object obj)
        {
            DbContentCatalog dbContentCatalog = (DbContentCatalog)obj;

            return(this.iD - dbContentCatalog.iD);
        }
Beispiel #17
0
        /// <summary>
        /// Deep copies the current DbContentCatalog to another instance of DbContentCatalog.
        /// </summary>
        /// <param name="DbContentCatalog">The DbContentCatalog to copy to.</param>
        /// <param name="isolation">Placeholders are used to isolate the DbContentCatalog from its children.</param>
        public void CopyTo(DbContentCatalog dbContentCatalog, bool isolation)
        {
            dbContentCatalog.iD                               = iD;
            dbContentCatalog.isPlaceHolder                    = isPlaceHolder;
            dbContentCatalog.isSynced                         = isSynced;
            dbContentCatalog.title                            = title;
            dbContentCatalog.description                      = description;
            dbContentCatalog.keywords                         = keywords;
            dbContentCatalog.status                           = status;
            dbContentCatalog.workflowMode                     = workflowMode;
            dbContentCatalog.commentsEnabled                  = commentsEnabled;
            dbContentCatalog.notifyOnComments                 = notifyOnComments;
            dbContentCatalog.enabled                          = enabled;
            dbContentCatalog.sortOrder                        = sortOrder;
            dbContentCatalog.icon                             = icon;
            dbContentCatalog.createDate                       = createDate;
            dbContentCatalog.modifyDate                       = modifyDate;
            dbContentCatalog.defaultTimeToPublish             = defaultTimeToPublish;
            dbContentCatalog.defaultTimeToExpire              = defaultTimeToExpire;
            dbContentCatalog.defaultTimeToArchive             = defaultTimeToArchive;
            dbContentCatalog.defaultKeywords                  = defaultKeywords;
            dbContentCatalog.defaultMenuLeftIcon              = defaultMenuLeftIcon;
            dbContentCatalog.defaultMenuRightIcon             = defaultMenuRightIcon;
            dbContentCatalog.menuLabel                        = menuLabel;
            dbContentCatalog.menuTooltip                      = menuTooltip;
            dbContentCatalog.menuEnabled                      = menuEnabled;
            dbContentCatalog.menuOrder                        = menuOrder;
            dbContentCatalog.menuLeftIcon                     = menuLeftIcon;
            dbContentCatalog.menuRightIcon                    = menuRightIcon;
            dbContentCatalog.menuBreakImage                   = menuBreakImage;
            dbContentCatalog.menuBreakCssClass                = menuBreakCssClass;
            dbContentCatalog.menuCssClass                     = menuCssClass;
            dbContentCatalog.menuCatalogCssClass              = menuCatalogCssClass;
            dbContentCatalog.menuCatalogSelectedCssClass      = menuCatalogSelectedCssClass;
            dbContentCatalog.menuCatalogChildSelectedCssClass = menuCatalogChildSelectedCssClass;
            dbContentCatalog.menuClipCssClass                 = menuClipCssClass;
            dbContentCatalog.menuClipSelectedCssClass         = menuClipSelectedCssClass;
            dbContentCatalog.menuClipChildSelectedCssClass    = menuClipChildSelectedCssClass;
            dbContentCatalog.menuClipChildExpandedCssClass    = menuClipChildExpandedCssClass;
            dbContentCatalog.menuOverrideFlags                = menuOverrideFlags;
            dbContentCatalog.menuIconFlags                    = menuIconFlags;

            if (parentCatalog != null)
            {
                if (isolation)
                {
                    dbContentCatalog.parentCatalog = parentCatalog.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.parentCatalog = parentCatalog.Copy(false);
                }
            }
            if (childCatalogs != null)
            {
                if (isolation)
                {
                    dbContentCatalog.childCatalogs = childCatalogs.Copy(true);
                }
                else
                {
                    dbContentCatalog.childCatalogs = childCatalogs.Copy(false);
                }
            }
            if (defaultClip != null)
            {
                if (isolation)
                {
                    dbContentCatalog.defaultClip = defaultClip.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.defaultClip = defaultClip.Copy(false);
                }
            }
            if (defaultStatus != null)
            {
                if (isolation)
                {
                    dbContentCatalog.defaultStatus = defaultStatus.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.defaultStatus = defaultStatus.Copy(false);
                }
            }
            if (defaultRating != null)
            {
                if (isolation)
                {
                    dbContentCatalog.defaultRating = defaultRating.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.defaultRating = defaultRating.Copy(false);
                }
            }
            if (defaultArchive != null)
            {
                if (isolation)
                {
                    dbContentCatalog.defaultArchive = defaultArchive.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.defaultArchive = defaultArchive.Copy(false);
                }
            }
            if (templates != null)
            {
                if (isolation)
                {
                    dbContentCatalog.templates = templates.Copy(true);
                }
                else
                {
                    dbContentCatalog.templates = templates.Copy(false);
                }
            }
            if (authorRole != null)
            {
                if (isolation)
                {
                    dbContentCatalog.authorRole = authorRole.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.authorRole = authorRole.Copy(false);
                }
            }
            if (editorRole != null)
            {
                if (isolation)
                {
                    dbContentCatalog.editorRole = editorRole.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.editorRole = editorRole.Copy(false);
                }
            }
            if (reviewerRole != null)
            {
                if (isolation)
                {
                    dbContentCatalog.reviewerRole = reviewerRole.NewPlaceHolder();
                }
                else
                {
                    dbContentCatalog.reviewerRole = reviewerRole.Copy(false);
                }
            }
        }
Beispiel #18
0
 /// <summary>
 /// Deep copies the current DbContentCatalog to another instance of DbContentCatalog.
 /// This method does not provide isolated copies; use overriden method for this feature.
 /// </summary>
 /// <param name="DbContentCatalog">The DbContentCatalog to copy to.</param>
 public void CopyTo(DbContentCatalog dbContentCatalog)
 {
     CopyTo(dbContentCatalog, false);
 }
Beispiel #19
0
        /// <summary>
        /// Clones DbContentCatalog object and clones child objects with cloning or replication.
        /// as the parent object.
        /// </summary>
        /// <returns> A new DbContentCatalog object reflecting the replicated DbContentCatalog object.</returns>
        public DbContentCatalog Clone()
        {
            DbContentCatalog clonedDbContentCatalog = new DbContentCatalog();

            clonedDbContentCatalog.iD                               = iD;
            clonedDbContentCatalog.isSynced                         = isSynced;
            clonedDbContentCatalog.title                            = title;
            clonedDbContentCatalog.description                      = description;
            clonedDbContentCatalog.keywords                         = keywords;
            clonedDbContentCatalog.status                           = status;
            clonedDbContentCatalog.workflowMode                     = workflowMode;
            clonedDbContentCatalog.commentsEnabled                  = commentsEnabled;
            clonedDbContentCatalog.notifyOnComments                 = notifyOnComments;
            clonedDbContentCatalog.enabled                          = enabled;
            clonedDbContentCatalog.sortOrder                        = sortOrder;
            clonedDbContentCatalog.icon                             = icon;
            clonedDbContentCatalog.createDate                       = createDate;
            clonedDbContentCatalog.modifyDate                       = modifyDate;
            clonedDbContentCatalog.defaultTimeToPublish             = defaultTimeToPublish;
            clonedDbContentCatalog.defaultTimeToExpire              = defaultTimeToExpire;
            clonedDbContentCatalog.defaultTimeToArchive             = defaultTimeToArchive;
            clonedDbContentCatalog.defaultKeywords                  = defaultKeywords;
            clonedDbContentCatalog.defaultMenuLeftIcon              = defaultMenuLeftIcon;
            clonedDbContentCatalog.defaultMenuRightIcon             = defaultMenuRightIcon;
            clonedDbContentCatalog.menuLabel                        = menuLabel;
            clonedDbContentCatalog.menuTooltip                      = menuTooltip;
            clonedDbContentCatalog.menuEnabled                      = menuEnabled;
            clonedDbContentCatalog.menuOrder                        = menuOrder;
            clonedDbContentCatalog.menuLeftIcon                     = menuLeftIcon;
            clonedDbContentCatalog.menuRightIcon                    = menuRightIcon;
            clonedDbContentCatalog.menuBreakImage                   = menuBreakImage;
            clonedDbContentCatalog.menuBreakCssClass                = menuBreakCssClass;
            clonedDbContentCatalog.menuCssClass                     = menuCssClass;
            clonedDbContentCatalog.menuCatalogCssClass              = menuCatalogCssClass;
            clonedDbContentCatalog.menuCatalogSelectedCssClass      = menuCatalogSelectedCssClass;
            clonedDbContentCatalog.menuCatalogChildSelectedCssClass = menuCatalogChildSelectedCssClass;
            clonedDbContentCatalog.menuClipCssClass                 = menuClipCssClass;
            clonedDbContentCatalog.menuClipSelectedCssClass         = menuClipSelectedCssClass;
            clonedDbContentCatalog.menuClipChildSelectedCssClass    = menuClipChildSelectedCssClass;
            clonedDbContentCatalog.menuClipChildExpandedCssClass    = menuClipChildExpandedCssClass;
            clonedDbContentCatalog.menuOverrideFlags                = menuOverrideFlags;
            clonedDbContentCatalog.menuIconFlags                    = menuIconFlags;


            if (parentCatalog != null)
            {
                clonedDbContentCatalog.parentCatalog = parentCatalog;
            }

            if (childCatalogs != null)
            {
                clonedDbContentCatalog.childCatalogs = childCatalogs.Clone();
            }

            if (defaultClip != null)
            {
                clonedDbContentCatalog.defaultClip = defaultClip;
            }

            if (defaultStatus != null)
            {
                clonedDbContentCatalog.defaultStatus = defaultStatus;
            }

            if (defaultRating != null)
            {
                clonedDbContentCatalog.defaultRating = defaultRating;
            }

            if (defaultArchive != null)
            {
                clonedDbContentCatalog.defaultArchive = defaultArchive;
            }

            if (templates != null)
            {
                clonedDbContentCatalog.templates = templates.Clone();
            }

            if (authorRole != null)
            {
                clonedDbContentCatalog.authorRole = authorRole;
            }

            if (editorRole != null)
            {
                clonedDbContentCatalog.editorRole = editorRole;
            }

            if (reviewerRole != null)
            {
                clonedDbContentCatalog.reviewerRole = reviewerRole;
            }

            return(clonedDbContentCatalog);
        }