/// <summary> /// This is the init/copy method for this class. /// It should be used by the children classes in the constructor in order to correctly fill the properties of the object. /// </summary> /// <param name="objToCopy"></param> protected bool Init(SnippetComment objToCopy) { if (objToCopy == null) { return(false); } //save the values of the properties with private setters: CommentID = objToCopy.CommentID; SnippetID = objToCopy.SnippetID; CommenterID = objToCopy.CommenterID; CommenterFullName = objToCopy.CommenterFullName; Content = objToCopy.Content; SnippetCommentDate = objToCopy.SnippetCommentDate; DisqusPostId = objToCopy.DisqusPostId; DisqusAuthorUID = objToCopy.DisqusAuthorUID; //if the object to copy comes from a JSON deserialization, tke the arguments from the helper class: if (objToCopy is SnippetCommentComm) { SnippetCommentComm jsonObj = (SnippetCommentComm)objToCopy; CommentID = (objToCopy.CommentID > 0) ? objToCopy.CommentID : jsonObj.CommID; SnippetCommentDate = (objToCopy.CommentID > 0) ? objToCopy.SnippetCommentDate : jsonObj.CommSnippetCommentDate; } return(true); }
/// <summary> /// This is the init/copy method for this class. /// It should be used by the children classes in the constructor in order to correctly fill the properties of the object. /// </summary> /// <param name="objToCopy"></param> protected bool Init(SnippetComment objToCopy) { if (objToCopy == null) return false; //save the values of the properties with private setters: CommentID = objToCopy.CommentID; SnippetID = objToCopy.SnippetID; CommenterID = objToCopy.CommenterID; CommenterFullName = objToCopy.CommenterFullName; Content = objToCopy.Content; SnippetCommentDate = objToCopy.SnippetCommentDate; DisqusPostId = objToCopy.DisqusPostId; DisqusAuthorUID = objToCopy.DisqusAuthorUID; //if the object to copy comes from a JSON deserialization, tke the arguments from the helper class: if (objToCopy is SnippetCommentComm) { SnippetCommentComm jsonObj = (SnippetCommentComm)objToCopy; CommentID = (objToCopy.CommentID > 0) ? objToCopy.CommentID : jsonObj.CommID; SnippetCommentDate = (objToCopy.CommentID > 0) ? objToCopy.SnippetCommentDate : jsonObj.CommSnippetCommentDate; } return true; }
/// <summary> /// Adds the given comment to the list of comments, if not yet present. /// This procedure modifies only the local in-memory content of the snippet. /// </summary> /// <param name="addingComment"></param> public void AddComment(SnippetComment addingComment) { if (addingComment == null) return; //if the comment is not yet present in the list, add it: if (m_comments == null) m_comments = new List<SnippetComment>(); m_comments.Add(addingComment); }