private void CompleteInterfaces( ICompletionContext context, ObjectTypeDefinition definition) { if (ClrType != typeof(object)) { foreach (Type interfaceType in ClrType.GetInterfaces()) { if (context.TryGetType( new ClrTypeReference(interfaceType, TypeContext.Output), out InterfaceType type)) { _interfaces[type.Name] = type; } } } foreach (ITypeReference interfaceRef in definition.Interfaces) { if (!context.TryGetType(interfaceRef, out InterfaceType type)) { // TODO : resources context.ReportError(SchemaErrorBuilder.New() .SetMessage( "COULD NOT RESOLVE INTERFACE") .SetCode(ErrorCodes.Schema.MissingType) .SetTypeSystemObject(this) .AddSyntaxNode(SyntaxNode) .Build()); } _interfaces[type.Name] = type; } }
private void CompleteInterfaces( ITypeInitializationContext context) { if (ClrType != typeof(object)) { Type[] possibleInterfaceTypes = ClrType.GetInterfaces(); for (int i = 0; i < possibleInterfaceTypes.Length; i++) { InterfaceType type = context.GetType <InterfaceType>( new TypeReference( possibleInterfaceTypes[i], TypeContext.Output)); if (type != null) { _interfaceMap[type.Name] = type; } } } foreach (InterfaceType interfaceType in _interfaces .Select(t => context.GetType <InterfaceType>(t)) .Where(t => t != null)) { if (!_interfaceMap.ContainsKey(interfaceType.Name)) { _interfaceMap[interfaceType.Name] = interfaceType; } } }
// Get the list of all interfaces that are implemented by this type. public override Type[] GetInterfaces() { if (type != null) { return(type.GetInterfaces()); } else if (interfaces == null) { return(new Type [0]); } else { return((Type[])(interfaces.Clone())); } }