private static TypeVariableReference CreateTypeVariableReferenceFromPrimitiveType( this TypeVariableSet typeVariableSet, NIType type, Dictionary <NIType, TypeVariableReference> genericTypeParameters) { var implementedTraits = new List <TypeVariableReference>(); if (type.IsInteger() || type.IsBoolean()) { // TODO: cache parameterless trait references? implementedTraits.Add(typeVariableSet.CreateReferenceToParameterlessTraitType("Display")); implementedTraits.Add(typeVariableSet.CreateReferenceToParameterlessTraitType("Clone")); implementedTraits.Add(typeVariableSet.CreateReferenceToParameterlessTraitType("Copy")); } else if (type.IsString()) { implementedTraits.Add(typeVariableSet.CreateReferenceToParameterlessTraitType("Display")); implementedTraits.Add(typeVariableSet.CreateReferenceToParameterlessTraitType("Clone")); } else { throw new NotSupportedException("Unknown non-class type: " + type); } return(typeVariableSet.CreateReferenceToConcreteType( type, new TypeVariableReference[0], new Dictionary <string, TypeVariableReference>(), implementedTraits.ToArray())); }
private static TypeVariableReference CreateTypeVariableReferenceFromInterfaceNIType( this TypeVariableSet typeVariableSet, NIType type, Dictionary <NIType, TypeVariableReference> genericTypeParameters) { string typeName = type.GetName(); if (type.IsGenericType()) { TypeVariableReference[] parameterTypeVariables = type .GetGenericParameters() .Select(t => typeVariableSet.CreateTypeVariableReferenceFromNIType(t, genericTypeParameters)) .ToArray(); return(typeVariableSet.CreateReferenceToTraitType(typeName, parameterTypeVariables)); } return(typeVariableSet.CreateReferenceToParameterlessTraitType(typeName)); }