示例#1
0
        /// <summary>
        /// Called whenever the comments collection has changed.
        /// </summary>
        /// <param name="sender">Object that has raised the event</param>
        /// <param name="e">Information about the change</param>
        protected void OnCommentsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (Comment comment in e.NewItems)
                {
                    _Comment implComment = comment as _Comment;
                    if (implComment == null)
                    {
                        throw new ArgumentException("A comment element created outside the model " +
                                                    "library has been added to this element!");
                    }

                    adaptedElement.OwnedComment.Add(implComment.Adaptee);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (Comment comment in e.OldItems)
                {
                    _Comment implComment = (_Comment)comment;

                    adaptedElement.OwnedComment.Remove(implComment.Adaptee);
                }
            }
        }
示例#2
0
        public Comment AddComment(string body)
        {
            Comment cmnt = new _Comment(this, schema);

            comments.Add(cmnt);
            cmnt.Body = body;
            return(cmnt);
        }
示例#3
0
文件: _Comment.cs 项目: mff-uk/xcase
        public override Element Clone(Model targetModel, ElementCopiesMap createdCopies)
        {
            Element _annotatedElement;

            if (targetModel != this.Schema.Model || createdCopies.ContainsKey(AnnotatedElement))
            {
                _annotatedElement = createdCopies[AnnotatedElement];
            }
            else
            {
                _annotatedElement = AnnotatedElement;
            }
            Comment clone = new _Comment(_annotatedElement, targetModel.Schema);

            return(clone);
        }