public static DescriptorBasedMessageTypeInfo Create(Type mappedType, RosMessageDescriptor messageDescriptor, MessageTypeRegistry registry) { var dependencies = new List <IRosMessageTypeInfo>(); foreach (var dependentField in messageDescriptor.Fields) { if (dependentField.RosType.IsBuiltIn) { continue; } Type mappedFieldType; if (dependentField.RosType.IsArray) { mappedFieldType = dependentField .Type .GetInterfaces() .Where(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable <>)) .Select(t => t.GetGenericArguments()[0]) .FirstOrDefault(); } else { mappedFieldType = dependentField.Type; } var dependency = registry.GetOrCreateMessageTypeInfo(mappedFieldType); dependencies.Add(dependency); } return(new DescriptorBasedMessageTypeInfo(mappedType, messageDescriptor, dependencies)); }
public AttributedMessageTypeInfoFactory(MessageTypeRegistry typeRegistry) { _typeRegistry = typeRegistry ?? throw new ArgumentNullException(nameof(typeRegistry)); }