public FuncAsyncConverter GetConverter()

in src/Microsoft.Azure.WebJobs.Host/Bindings/ConverterManager.cs [340:422]


        public FuncAsyncConverter GetConverter<TAttribute>(Type typeSource, Type typeDest)
            where TAttribute : Attribute
        {
            // Give precedence to exact matches.
            // This lets callers override any other rules (like JSON binding).
            // TSrc --> TDest
            var exactMatch = TryGetConverter<TAttribute>(typeSource, typeDest, this._exactConverters);
            if (exactMatch != null)
            {
                return exactMatch;
            }

            // Inheritence (also covers idempotency)
            if (typeDest.IsAssignableFrom(typeSource))
            {
                // Skip implicit conversions to object since that's everybody's base 
                // class and BindToInput<attr,Object> would catch everything. 
                // Users can still register an explicit T-->object converter if they want to 
                // support it. 
                if (typeDest != typeof(Object))
                {
                    return IdentityConverter;
                }
            }

            // General Open converter lookup.
            // If they registered an Object-->TDest converter, that will get picked up here
            // and give them broad control over creating a TDest from anything. 
            {
                var builder = TryGetOpenConverter(typeSource, typeDest, typeof(TAttribute));
                if (builder != null)
                {
                    var converter = builder(typeSource, typeDest);
                    return converter;
                }
            }

            // Helper to treat IEnumerabe<JObject> as a JArray. 
            // TSrc --> IEnum<JObject> --> JArray
            if (typeDest == typeof(JArray))
            {
                var converter = GetComposition<TAttribute, IEnumerable<JObject>>(typeSource, typeDest);
                if (converter != null)
                {
                    return converter;
                }           
            }

            // We already matched against (string --> Dest) in the general case
            // but now allow some well-defined intermediate conversions. 
            // If this is "wrong" for your type, then it should provide an exact match to override.
            // Byte[] --[builtin]--> String --> TDest
            if (typeSource == typeof(byte[]))
            {
                var converter = GetComposition<TAttribute, string>(typeSource, typeDest);
                if (converter != null)
                {
                    return converter;
                }
            }

            // General JSON Serialization rule. 
            // Can we convert from src to dest via a JObject serialization?
            // Common example is Poco --> Jobject --> QueueMessage
            {
                var converter = GetComposition<TAttribute, JObject>(typeSource, typeDest);
                if (converter != null)
                {
                    return converter;
                }
            }

            {
                // Common for blob and stream-based systems.
                var converter = GetComposition<TAttribute, Stream>(typeSource, typeDest);
                if (converter != null)
                {
                    return converter;
                }
            }

            return null;          
        }