当前位置: 首页>>代码示例>>C#>>正文


C# CodeCommentStatementCollection.AddRange方法代码示例

本文整理汇总了C#中System.CodeDom.CodeCommentStatementCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# CodeCommentStatementCollection.AddRange方法的具体用法?C# CodeCommentStatementCollection.AddRange怎么用?C# CodeCommentStatementCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.CodeDom.CodeCommentStatementCollection的用法示例。


在下文中一共展示了CodeCommentStatementCollection.AddRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Constructor1_Deny_Unrestricted

		public void Constructor1_Deny_Unrestricted ()
		{
			CodeCommentStatementCollection coll = new CodeCommentStatementCollection (array);
			coll.CopyTo (array, 0);
			Assert.AreEqual (1, coll.Add (ccs), "Add");
			Assert.AreSame (ccs, coll[0], "this[int]");
			coll.AddRange (array);
			coll.AddRange (coll);
			Assert.IsTrue (coll.Contains (ccs), "Contains");
			Assert.AreEqual (0, coll.IndexOf (ccs), "IndexOf");
			coll.Insert (0, ccs);
			coll.Remove (ccs);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CodeCommentStatementCollectionCas.cs

示例2: AddRange_Self

		public void AddRange_Self ()
		{
			CodeCommentStatementCollection coll = new CodeCommentStatementCollection ();
			coll.Add (new CodeCommentStatement ());
			Assert.AreEqual (1, coll.Count, "#1");
			coll.AddRange (coll);
			Assert.AreEqual (2, coll.Count, "#2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:CodeCommentStatementCollectionTest.cs

示例3: AddRange_Null_Collection

		public void AddRange_Null_Collection ()
		{
			CodeCommentStatementCollection coll = new CodeCommentStatementCollection ();
			coll.AddRange ((CodeCommentStatementCollection) null);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:CodeCommentStatementCollectionTest.cs

示例4: AddRange

		public void AddRange ()
		{
			CodeCommentStatement ccs1 = new CodeCommentStatement ();
			CodeCommentStatement ccs2 = new CodeCommentStatement ();
			CodeCommentStatement ccs3 = new CodeCommentStatement ();

			CodeCommentStatementCollection coll1 = new CodeCommentStatementCollection ();
			coll1.Add (ccs1);
			coll1.Add (ccs2);

			CodeCommentStatementCollection coll2 = new CodeCommentStatementCollection ();
			coll2.Add (ccs3);
			coll2.AddRange (coll1);
			Assert.AreEqual (3, coll2.Count, "#1");
			Assert.AreEqual (1, coll2.IndexOf (ccs1), "#2");
			Assert.AreEqual (2, coll2.IndexOf (ccs2), "#3");
			Assert.AreEqual (0, coll2.IndexOf (ccs3), "#4");

			CodeCommentStatementCollection coll3 = new CodeCommentStatementCollection ();
			coll3.Add (ccs3);
			coll3.AddRange (new CodeCommentStatement[] { ccs1, ccs2 });
			Assert.AreEqual (3, coll2.Count, "#5");
			Assert.AreEqual (1, coll2.IndexOf (ccs1), "#6");
			Assert.AreEqual (2, coll2.IndexOf (ccs2), "#7");
			Assert.AreEqual (0, coll2.IndexOf (ccs3), "#8");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:26,代码来源:CodeCommentStatementCollectionTest.cs

示例5: GenerateCustomAttributes

        /// <summary>
        /// Generates code for the given set of custom attributes
        /// </summary>
        /// <param name="proxyGenerator">Root client proxy generator</param>
        /// <param name="referencingType">The referencing type</param>
        /// <param name="getLogWarningMessage">The function to call to get the warning message to be logged</param>
        /// <param name="attributes">Collection of attributes for which to generate code</param>
        /// <param name="comments">Collection of comments that should be updated if errors are discovered.</param>
        /// <param name="customCommentHeader">A custom comment header that will be displayed for any generated comment errors.</param>
        /// <param name="forcePropagation">Indicates whether or not to force attribute propagation.</param>
        /// <returns>The collection of generated attribute declarations corresponding to <paramref name="attributes"/></returns>
        private static IEnumerable<CodeAttributeDeclaration> GenerateCustomAttributes(CodeDomClientCodeGenerator proxyGenerator, CodeTypeDeclaration referencingType, Func<AttributeBuilderException, string> getLogWarningMessage, IEnumerable<Attribute> attributes, CodeCommentStatementCollection comments, string customCommentHeader, bool forcePropagation)
        {
            bool emittedErrorCommentHeader = false;
            List<CodeAttributeDeclaration> result = new List<CodeAttributeDeclaration>(attributes.Count());

            // Enumerate over attributes sorted by name.  Here, we sort by name to ensure that our
            // generated baselines (including possible error comments!) are ordered consistently.
            foreach (Attribute attribute in attributes.OrderBy(a => a.GetType().Name))
            {
                Type attributeType = attribute.GetType();

                // Check if this attribute should be blocked
                if (IsAttributeBlocked(attributeType))
                {
                    continue;
                }

                bool attributePropagated = false;
                bool isDataAnnotationsAttribute = string.Equals(attributeType.Namespace, typeof(ValidationAttribute).Namespace, StringComparison.Ordinal);

                ICustomAttributeBuilder cab = GetCustomAttributeBuilder(attributeType);

                if (cab != null)
                {
                    AttributeDeclaration attributeDeclaration = null;
                    // If the attempt to build the attribute fails, log a clean error.
                    // One common exception path is InvalidOperationException arising from
                    // attributes that have been improperly constructed (see DisplayAttribute)
                    try
                    {
                        attributeDeclaration = cab.GetAttributeDeclaration(attribute);
                    }
                    catch (AttributeBuilderException attributeBuilderException)
                    {
                        // Ensure we've generated the attribute generation failure error header
                        GenerateCustomAttributesErrorCommentHeader(comments, customCommentHeader, ref emittedErrorCommentHeader);

                        // Generate comments stating the attribute couldn't be generated
                        comments.AddRange(ConstructCodeAttributeFailureComments(attributeBuilderException.Message));

                        // Log the build warning if a method was specified to get the warning message
                        if (getLogWarningMessage != null)
                        {
                            string warningMessage = getLogWarningMessage(attributeBuilderException);
                            proxyGenerator.LogWarning(warningMessage);
                        }

                        // Move on to the next attribute
                        continue;
                    }

                    // Null is acceptable indicator that code-gen was not possible.
                    if (attributeDeclaration != null)
                    {
                        if (!forcePropagation)
                        {
                            // Verify attribute's shared type|property|method requirements are met
                            ValidateAttributeDeclarationRequirements(proxyGenerator, attributeDeclaration);
                        }

                        if (attributeDeclaration.HasErrors)
                        {
                            // Only generate comments if the attribute is a DataAnnotations attribute
                            if (isDataAnnotationsAttribute)
                            {
                                // Ensure we've generated the attribute generation failure error header
                                GenerateCustomAttributesErrorCommentHeader(comments, customCommentHeader, ref emittedErrorCommentHeader);

                                // Generate attribute and an error message as comments
                                comments.AddRange(ConstructCodeAttributeFailureComments(proxyGenerator, attributeDeclaration));
                            }
                        }
                        else
                        {
                            // Generate the attribute declaration
                            CodeAttributeDeclaration codeAttributeDeclaration = CreateCodeAttributeDeclaration(proxyGenerator, referencingType, attributeDeclaration);
                            result.Add(codeAttributeDeclaration);
                            attributePropagated = true;
                        }
                    }
                }

                // We generate VS warnings in certain scenarios:
                //  - A DataAnnotation attribute type was not available on the client, user needs to add a reference.
                //  - An attribute subclassed ValidationAttribute (custom or framework) and we couldn't build it.
                if (!attributePropagated)
                {
                    // Was it a DA attribute that wasn't available?  If so, log a warning.
                    if (isDataAnnotationsAttribute)
//.........这里部分代码省略.........
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:101,代码来源:CustomAttributeGenerator.cs


注:本文中的System.CodeDom.CodeCommentStatementCollection.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。