コード例 #1
0
        /// <summary>
        /// Adds the interface namespace references to the container referred to by
        /// <paramref name="cursor"/>.
        /// </summary>
        /// <param name="cursor">The cursor.</param>
        /// <param name="namespaceNodes">The namespace nodes.</param>
        /// <returns>A reference to the object on which the method was invoked.</returns>
        public static LanguageElement AddNamespaceReferences(
            this LanguageElement cursor,
            IEnumerable <NamespaceReference> namespaceNodes)
        {
            if (cursor == null)
            {
                throw new ArgumentNullException("cursor", "cursor is null.");
            }

            if (namespaceNodes == null)
            {
                throw new ArgumentNullException("namespaceNodes", "namespaceNodes is null.");
            }

            Contract.EndContractBlock();

            foreach (NamespaceReference ns in namespaceNodes)
            {
                Contract.Assert(cursor != null);
                if (ns == null)
                {
                    continue;
                }

                if (ns.Comments != null)
                {
                    ns.Comments.Clear();
                }

                cursor.AddNode(ns);
            }

            return(cursor);
        }
コード例 #2
0
        /// <summary>
        /// Adds the default return statement.
        /// </summary>
        /// <param name="contractElement">The contract element.</param>
        /// <param name="memberTypeReference">The member type reference.</param>
        private void AddDefaultReturn(LanguageElement contractElement, TypeReferenceExpression memberTypeReference)
        {
            Contract.Requires(contractElement != null, "contractElement is null.");
            Contract.Requires(memberTypeReference != null, "memberTypeReference is null.");

            var returnValue = !this.CodeRushProxy.Language.IsCSharp ?
                              this.CodeRushProxy.Language.GetNullReferenceExpression() :
                              new DefaultValueExpression(memberTypeReference);

            var methodReturn = new Return(returnValue);

            methodReturn.AddCommentNode(new Comment()
            {
                Name = RuntimeIgnored, CommentType = CommentType.SingleLine
            });
            contractElement.AddNode(methodReturn);
        }
コード例 #3
0
    /// <summary>
    /// Adds the default return statement.
    /// </summary>
    /// <param name="contractElement">The contract element.</param>
    /// <param name="memberTypeReference">The member type reference.</param>
    private void AddDefaultReturn(LanguageElement contractElement, TypeReferenceExpression memberTypeReference)
    {
      Contract.Requires(contractElement != null, "contractElement is null.");
      Contract.Requires(memberTypeReference != null, "memberTypeReference is null.");

      var returnValue = !this.CodeRushProxy.Language.IsCSharp ?
        this.CodeRushProxy.Language.GetNullReferenceExpression() :
        new DefaultValueExpression(memberTypeReference);

      var methodReturn = new Return(returnValue);
      methodReturn.AddCommentNode(new Comment() { Name = RuntimeIgnored, CommentType = CommentType.SingleLine });
      contractElement.AddNode(methodReturn);
    }