本文整理汇总了C#中System.CodeDom.CodeTypeParameterCollection类的典型用法代码示例。如果您正苦于以下问题:C# CodeTypeParameterCollection类的具体用法?C# CodeTypeParameterCollection怎么用?C# CodeTypeParameterCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeTypeParameterCollection类属于System.CodeDom命名空间,在下文中一共展示了CodeTypeParameterCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例2: Constructor1_NullItem
public void Constructor1_NullItem ()
{
CodeTypeParameter[] typeParams = new CodeTypeParameter[] {
new CodeTypeParameter (), null };
CodeTypeParameterCollection coll = new CodeTypeParameterCollection (
typeParams);
}
示例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]);
}
}
示例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;
}
示例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]);
}
}
示例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;
}
示例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;
}
示例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");
}
示例9: Remove_NotInCollection
public void Remove_NotInCollection ()
{
CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
coll.Remove (new CodeTypeParameter ());
}
示例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");
}
示例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(')');
}
}
示例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);
}
}
示例13: Add_Null
public void Add_Null () {
CodeTypeParameterCollection coll = new CodeTypeParameterCollection ();
coll.Add ((CodeTypeParameter) null);
}
示例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");
}
示例15: ValidateTypeParameters
private void ValidateTypeParameters(CodeTypeParameterCollection parameters) {
for (int i=0; i<parameters.Count; i++) {
ValidateTypeParameter(parameters[i]);
}
}