📄 commentcollection.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Collections;
//*********************************************************************
//
// CommentCollection Class
//
// This class represents a collection of comments.
// It inherits from an ArrayList and uses a Hashtable internally.
//
//*********************************************************************
public class CommentCollection : ArrayList {
Hashtable hashComments = new Hashtable();
//*********************************************************************
//
// CommentCollection Constructor
//
// Initializes a new instance of the CommentCollection class.
//
//*********************************************************************
public CommentCollection() : base() {}
//*********************************************************************
//
// this indexer
//
// Adds a new comment to the ArrayList and Hashtable.
//
//*********************************************************************
override public object this[int index] {
set {
hashComments[((CommentInfo)value).ContentPageID] = value;
base[index] = value;
}
get {
return (CommentInfo)base[index];
}
}
//*********************************************************************
//
// Add Method
//
// Adds a new comment to the ArrayList and Hashtable.
//
//*********************************************************************
override public int Add(object value) {
hashComments[((CommentInfo)value).ContentPageID] = value;
return base.Add(value);
}
//*********************************************************************
//
// GetChildren Method
//
// Gets all the immediate child comments by iterating through
// the ArrayList.
//
//*********************************************************************
public CommentCollection GetChildren(int replyID) {
CommentCollection colChildren = new CommentCollection();
IEnumerator e = this.GetEnumerator();
while (e.MoveNext())
if (((CommentInfo)e.Current).ReplyID == replyID)
colChildren.Add(e.Current);
return colChildren;
}
//*********************************************************************
//
// GetReplyLevel Method
//
// Gets the nesting level of a comment.
//
//*********************************************************************
public int GetReplyLevel(CommentInfo comment) {
int level = -1;
while (comment != null) {
level ++;
comment = (CommentInfo)hashComments[comment.ReplyID];
if (level > 50)
break;
}
return level;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -