Esempio n. 1
0
        public static TypeParameter ReadTypeParameter(BinaryReader reader, INameDecoder nameTable, IDomObjectTable objectTable)
        {
            string        name = ReadString(reader, nameTable);
            TypeParameter tp   = new TypeParameter(name);

            // Flags
            tp.TypeParameterModifier = (TypeParameterModifier)reader.ReadByte();

            // Variance

            tp.Variance = (TypeParameterVariance)reader.ReadByte();

            // Constraints

            uint count = ReadUInt(reader, 1000);

            while (count-- > 0)
            {
                tp.AddConstraint(ReadReturnType(reader, nameTable, objectTable));
            }

            // Attributes

            count = ReadUInt(reader, 1000);
            while (count-- > 0)
            {
                tp.AddAttribute(ReadAttribute(reader, nameTable, objectTable));
            }

            return(tp);
        }
Esempio n. 2
0
        public void CloneTest()
        {
            TypeParameter typeParameter = new TypeParameter();

            typeParameter.Name = "T";
            typeParameter.AddConstraint("IDisposable");
            typeParameter.AddConstraint("new()");

            TypeParameter clone = typeParameter.Clone() as TypeParameter;

            Assert.IsNotNull(clone, "Clone should return a TypeParameter instance.");

            Assert.AreEqual(typeParameter.Name, clone.Name, "Name property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints.Count, clone.Constraints.Count, "Constraints property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints[0], clone.Constraints[0], "Constraints property was not copied correctly.");
            Assert.AreEqual(typeParameter.Constraints[1], clone.Constraints[1], "Constraints property was not copied correctly.");
        }
			TypeParameter ConvertTemplateDefinition (ICSharpCode.NRefactory.Ast.TemplateDefinition template)
			{
				TypeParameter parameter = new TypeParameter (template.Name);
				foreach (ICSharpCode.NRefactory.Ast.TypeReference typeRef in template.Bases) {
					if (typeRef.Type == "constraint: struct")
						parameter.ValueTypeRequired = true; else if (typeRef.Type == "constraint: class")
						parameter.ClassRequired = true; else if (typeRef.Type == "constraint: new")
						parameter.ConstructorRequired = true; else {
						DomReturnType rt = ConvertReturnType (typeRef);
						parameter.AddConstraint (rt);
					}
				}
				return parameter;
			}
        public static TypeParameter ReadTypeParameter(BinaryReader reader, INameDecoder nameTable)
        {
            string        name = ReadString(reader, nameTable);
            TypeParameter tp   = new TypeParameter(name);

            // Flags

            byte f = reader.ReadByte();

            if ((f & 1) != 0)
            {
                tp.ClassRequired = true;
            }
            if ((f & 2) != 0)
            {
                tp.ValueTypeRequired = true;
            }
            if ((f & 4) != 0)
            {
                tp.ConstructorRequired = true;
            }

            // Variance

            tp.Variance = (TypeParameterVariance)reader.ReadByte();

            // Constraints

            uint count = ReadUInt(reader, 1000);

            while (count-- > 0)
            {
                tp.AddConstraint(ReadReturnType(reader, nameTable));
            }

            // Attributes

            count = ReadUInt(reader, 1000);
            while (count-- > 0)
            {
                tp.AddAttribute(ReadAttribute(reader, nameTable));
            }

            return(tp);
        }
Esempio n. 5
0
		public static TypeParameter ReadTypeParameter (BinaryReader reader, INameDecoder nameTable, IDomObjectTable objectTable)
		{
			string name = ReadString (reader, nameTable);
			TypeParameter tp = new TypeParameter (name);
			
			// Flags
			tp.TypeParameterModifier = (TypeParameterModifier)reader.ReadByte ();
			
			// Variance 

			tp.Variance = (TypeParameterVariance)reader.ReadByte ();
			
			// Constraints
			
			uint count = ReadUInt (reader, 1000);
			while (count-- > 0)
				tp.AddConstraint (ReadReturnType (reader, nameTable, objectTable));

			// Attributes
			
			count = ReadUInt (reader, 1000);
			while (count-- > 0)
				tp.AddAttribute (ReadAttribute (reader, nameTable, objectTable));

			return tp;
		}
		public static TypeParameter ReadTypeParameter (BinaryReader reader, INameDecoder nameTable)
		{
			string name = ReadString (reader, nameTable);
			TypeParameter tp = new TypeParameter (name);
			
			// Flags
			
			byte f = reader.ReadByte ();
			if ((f & 1) != 0)
				tp.ClassRequired = true;
			if ((f & 2) != 0)
				tp.ValueTypeRequired = true;
			if ((f & 4) != 0)
				tp.ConstructorRequired = true;

			// Variance 

			tp.Variance = (TypeParameterVariance)reader.ReadByte ();

			// Constraints
			
			uint count = ReadUInt (reader, 1000);
			while (count-- > 0)
				tp.AddConstraint (ReadReturnType (reader, nameTable));

			// Attributes
			
			count = ReadUInt (reader, 1000);
			while (count-- > 0)
				tp.AddAttribute (ReadAttribute (reader, nameTable));

			return tp;
		}