• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CodeDom.CodeTypeParameterCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CodeTypeParameterCollection类属于System.CodeDom命名空间,在下文中一共展示了CodeTypeParameterCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Constructor0

		public void Constructor0 ()
		{
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
			Assert.IsFalse (((IList) coll).IsFixedSize, "#1");
			Assert.IsFalse (((IList) coll).IsReadOnly, "#2");
			Assert.AreEqual (0, coll.Count, "#3");
			Assert.IsFalse (((ICollection) coll).IsSynchronized, "#4");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:CodeTypeParameterCollectionTest.cs


示例2: Constructor1_NullItem

		public void Constructor1_NullItem ()
		{
			CodeTypeParameter[] typeParams = new CodeTypeParameter[] { 
				new CodeTypeParameter (), null };

			CodeTypeParameterCollection coll = new CodeTypeParameterCollection (
				typeParams);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:8,代码来源:CodeTypeParameterCollectionTest.cs


示例3: AddRange

 public void AddRange(CodeTypeParameterCollection value) {
     if (value == null) {
         throw new ArgumentNullException("value");
     }
     int currentCount = value.Count;
     for (int i = 0; i < currentCount; i = ((i) + (1))) {
         this.Add(value[i]);
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:codetypeparametercollection.cs


示例4: GenerateDeserializer

 internal static CodeMemberMethod GenerateDeserializer(string name, string typeName, CodeTypeParameterCollection genericTypeParams = null)
 {
     var deserializer = new CodeMemberMethod { Name = name };
     deserializer.Attributes = (deserializer.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;
     deserializer.Attributes = (deserializer.Attributes & ~MemberAttributes.ScopeMask) | MemberAttributes.Static;
     deserializer.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(DeserializerMethodAttribute), CodeTypeReferenceOptions.GlobalReference)));
     deserializer.ReturnType = new CodeTypeReference(typeof(object));
     deserializer.Parameters.Add(new CodeParameterDeclarationExpression(typeof(Type), "expected"));
     deserializer.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(BinaryTokenStreamReader), CodeTypeReferenceOptions.GlobalReference), "stream"));
     return deserializer;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:11,代码来源:SerializerGenerationUtilities.cs


示例5: AddRange

		public void AddRange (CodeTypeParameterCollection value)
		{
			if (value == null) {
				throw new ArgumentNullException ("value");
			}

			int count = value.Count;
			for (int i = 0; i < count; i++) {
				Add (value[i]);
			}
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:CodeTypeParameterCollection.cs


示例6: GenerateCopier

 internal static CodeMemberMethod GenerateCopier(string name, string typeName, CodeTypeParameterCollection genericTypeParams = null)
 {
     var copier = new CodeMemberMethod { Name = name };
     copier.Attributes = (copier.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;
     copier.Attributes = (copier.Attributes & ~MemberAttributes.ScopeMask) | MemberAttributes.Static;
     copier.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(CopierMethodAttribute), CodeTypeReferenceOptions.GlobalReference)));
     copier.ReturnType = new CodeTypeReference(typeof(object));
     copier.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "original"));
     copier.Statements.Add(new CodeVariableDeclarationStatement(typeName, "input", new CodeCastExpression(typeName, new CodeArgumentReferenceExpression("original"))));
     return copier;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:11,代码来源:SerializerGenerationUtilities.cs


示例7: GenerateSerializer

 internal static CodeMemberMethod GenerateSerializer(string name, string typeName, CodeTypeParameterCollection genericTypeParams = null)
 {
     var serializer = new CodeMemberMethod { Name = name };
     serializer.Attributes = (serializer.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;
     serializer.Attributes = (serializer.Attributes & ~MemberAttributes.ScopeMask) | MemberAttributes.Static;
     serializer.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(SerializerMethodAttribute), CodeTypeReferenceOptions.GlobalReference)));
     serializer.ReturnType = new CodeTypeReference(typeof(void));
     serializer.Parameters.Add(new CodeParameterDeclarationExpression(typeof(object), "original"));
     serializer.Parameters.Add(new CodeParameterDeclarationExpression(new CodeTypeReference(typeof(BinaryTokenStreamWriter), CodeTypeReferenceOptions.GlobalReference), "stream"));
     serializer.Parameters.Add(new CodeParameterDeclarationExpression(typeof(Type), "expected"));
     serializer.Statements.Add(new CodeVariableDeclarationStatement(typeName, "input", new CodeCastExpression(typeName, new CodeArgumentReferenceExpression("original"))));
     return serializer;
 }
开发者ID:stanroze,项目名称:orleans,代码行数:13,代码来源:SerializerGenerationUtilities.cs


示例8: Constructor1

		public void Constructor1 ()
		{
			CodeTypeParameter tp1 = new CodeTypeParameter ();
			CodeTypeParameter tp2 = new CodeTypeParameter ();

			CodeTypeParameter[] typeParams = new CodeTypeParameter[] { tp1, tp2 };
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection (
				typeParams);

			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (tp1), "#2");
			Assert.AreEqual (1, coll.IndexOf (tp2), "#3");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:13,代码来源:CodeTypeParameterCollectionTest.cs


示例9: Remove_NotInCollection

		public void Remove_NotInCollection ()
		{
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
			coll.Remove (new CodeTypeParameter ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:CodeTypeParameterCollectionTest.cs


示例10: Remove

		public void Remove ()
		{
			CodeTypeParameter ctp1 = new CodeTypeParameter ();
			CodeTypeParameter ctp2 = new CodeTypeParameter ();

			CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
			coll.Add (ctp1);
			coll.Add (ctp2);
			Assert.AreEqual (2, coll.Count, "#1");
			Assert.AreEqual (0, coll.IndexOf (ctp1), "#2");
			Assert.AreEqual (1, coll.IndexOf (ctp2), "#3");
			coll.Remove (ctp1);
			Assert.AreEqual (1, coll.Count, "#4");
			Assert.AreEqual (-1, coll.IndexOf (ctp1), "#5");
			Assert.AreEqual (0, coll.IndexOf (ctp2), "#6");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:16,代码来源:CodeTypeParameterCollectionTest.cs


示例11: OutputTypeParameters

 private void OutputTypeParameters(CodeTypeParameterCollection typeParameters)
 {
     if (typeParameters.Count != 0)
     {
         base.Output.Write("(Of ");
         bool flag = true;
         for (int i = 0; i < typeParameters.Count; i++)
         {
             if (flag)
             {
                 flag = false;
             }
             else
             {
                 base.Output.Write(", ");
             }
             base.Output.Write(typeParameters[i].Name);
             this.OutputTypeParameterConstraints(typeParameters[i]);
         }
         base.Output.Write(')');
     }
 }
开发者ID:laymain,项目名称:CodeDomUtils,代码行数:22,代码来源:VBCodeGenerator.cs


示例12: PopulateGenericParameters

        private static void PopulateGenericParameters(IGenericParameterProvider publicType, CodeTypeParameterCollection parameters)
        {
            foreach (var parameter in publicType.GenericParameters)
            {
                if (parameter.HasCustomAttributes)
                    throw new NotImplementedException("Attributes on type parameters is not supported. And weird");

                // A little hacky. Means we get "in" and "out" prefixed on any constraints, but it's either that
                // or add it as a custom attribute, which looks even weirder
                var name = parameter.Name;
                if (parameter.IsCovariant)
                    name = "out " + name;
                if (parameter.IsContravariant)
                    name = "in " + name;

                var typeParameter = new CodeTypeParameter(name)
                {
                    HasConstructorConstraint =
                        parameter.HasDefaultConstructorConstraint && !parameter.HasNotNullableValueTypeConstraint
                };
                if (parameter.HasNotNullableValueTypeConstraint)
                    typeParameter.Constraints.Add(" struct"); // Extra space is a hack!
                if (parameter.HasReferenceTypeConstraint)
                    typeParameter.Constraints.Add(" class");
                foreach (var constraint in parameter.Constraints.Where(t => t.FullName != "System.ValueType"))
                {
                    typeParameter.Constraints.Add(CreateCodeTypeReference(constraint.GetElementType()));
                }
                parameters.Add(typeParameter);
            }
        }
开发者ID:Particular,项目名称:ServiceControl.Plugin.Nsb6.CustomChecks,代码行数:31,代码来源:PublicApiGenerator.cs


示例13: Add_Null

		public void Add_Null () {
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
			coll.Add ((CodeTypeParameter) null);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:4,代码来源:CodeTypeParameterCollectionTest.cs


示例14: GetBasicReferenceMethod

 /// <summary>
 /// Generates a wrapper method that takes arguments of the original method.
 /// </summary>
 protected override CodeTypeMember GetBasicReferenceMethod(MethodInfo methodInfo, CodeTypeParameterCollection genericTypeParam, bool isObserver)
 {
     throw new NotImplementedException("GetBasicReferenceMethod");
 }
开发者ID:stanroze,项目名称:orleans,代码行数:7,代码来源:FSharpCodeGenerator.cs


示例15: ValidateTypeParameters

 private void ValidateTypeParameters(CodeTypeParameterCollection parameters) {
     for (int i=0; i<parameters.Count; i++) {
         ValidateTypeParameter(parameters[i]);
     }
 }
开发者ID:uQr,项目名称:referencesource,代码行数:5,代码来源:CodeValidator.cs


示例16: GenerateGenericsConstraints

		void GenerateGenericsConstraints (CodeTypeParameterCollection parameters)
		{
			int count = parameters.Count;
			if (count == 0)
				return;

			bool indented = false;
			
			for (int i = 0; i < count; i++) {
				CodeTypeParameter p = parameters [i];
				bool hasConstraints = (p.Constraints.Count != 0);
				Output.WriteLine ();
				if (!hasConstraints && !p.HasConstructorConstraint)
					continue;

				if (!indented) {
					++Indent;
					indented = true;
				}

				Output.Write ("where ");
				Output.Write (p.Name);
				Output.Write (" : ");

				for (int j = 0; j < p.Constraints.Count; j++) {
					if (j > 0)
						Output.Write (", ");
					OutputType (p.Constraints [j]);
				}

				if (p.HasConstructorConstraint) {
					if (hasConstraints)
						Output.Write (", ");
					Output.Write ("new");
					if (hasConstraints)
						Output.Write (" ");
					Output.Write ("()");
				}
			}

			if (indented)
				--Indent;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:43,代码来源:CSharpCodeGenerator.cs


示例17: GenerateGenericsParameters

		void GenerateGenericsParameters (CodeTypeParameterCollection parameters)
		{
			int count = parameters.Count;
			if (count == 0)
				return;

			Output.Write ('<');
			for (int i = 0; i < count - 1; ++i) {
				Output.Write (parameters [i].Name);
				Output.Write (", ");
			}
			Output.Write (parameters [count - 1].Name);
			Output.Write ('>');
		}
开发者ID:runefs,项目名称:Marvin,代码行数:14,代码来源:CSharpCodeGenerator.cs


示例18: Remove_Null

		public void Remove_Null ()
		{
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
			coll.Remove ((CodeTypeParameter) null);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:5,代码来源:CodeTypeParameterCollectionTest.cs


示例19: OutputTypeParameters

        /// <summary>
        /// Outputs type parameter declaration (part of generic type and generic method declaration).
        /// </summary>
        /// <remarks></remarks>
        private void OutputTypeParameters(CodeTypeParameterCollection typeParams)
        {
            int count;
            if (typeParams != null && (count = typeParams.Count) > 0)
            {
                Output.Write(Tokens.GenericBracketLeft);

                Output.Write(typeParams[0].Name);
                for (int i = 1; i < count; i++)
                {
                    Output.Write(Tokens.Comma + WhiteSpace.Space);
                    Output.Write(typeParams[i].Name);
                }

                Output.Write(Tokens.GenericBracketRight);
            }
        }
开发者ID:jdluzen,项目名称:Phalanger,代码行数:21,代码来源:PhpGenerator.CLR.cs


示例20: Constructor1_Null

		public void Constructor1_Null () {
			CodeTypeParameterCollection coll = new CodeTypeParameterCollection (
				(CodeTypeParameter[]) null);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:4,代码来源:CodeTypeParameterCollectionTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeDom.CodeTypeReference类代码示例发布时间:2022-05-26
下一篇:
C# CodeDom.CodeTypeParameter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap