Esempio n. 1
0
        public ControlReference GetFor(Type type, IEnumerable <UIHint> uiHints)
        {
            foreach (var uiHint in uiHints)
            {
                var uiHintControlMatch = UIHintControlMatcher.GetFor(uiHint);

                if (uiHintControlMatch != null)
                {
                    return(uiHintControlMatch);
                }
            }

            var typeControlMatch = TypeControlMatcher.GetFor(type);

            if (typeControlMatch != null)
            {
                return(typeControlMatch);
            }

            foreach (var uiHint in uiHints)
            {
                if (uiHint.Parameters.Any())
                {
                    continue;
                }

                if (Controls.ContainsKey(uiHint.Id))
                {
                    return(new ControlReference(uiHint.Id, new Dictionary <string, object>()));
                }
            }

            return(null);
        }
Esempio n. 2
0
        public IControlMatch GetFor(Type type, IEnumerable <UIHint> uiHints)
        {
            foreach (var uiHint in uiHints)
            {
                var match = UIHintControlMatcher.GetFor(uiHint);

                if (Logger.IsEnabled(LogLevel.Information))
                {
                    Logger.LogInformation($"Match for {JsonConvert.SerializeObject(uiHint, Formatting.None)}: {JsonConvert.SerializeObject(match, Formatting.None)}");
                }

                if (match != null)
                {
                    return(match);
                }
            }

            {
                var match = TypeControlMatcher.GetFor(type);

                if (match != null)
                {
                    return(match);
                }
            }

            foreach (var uiHint in uiHints)
            {
                if (uiHint.Parameters.Any())
                {
                    continue;
                }

                if (Controls.ContainsKey(uiHint.Id))
                {
                    return(new UIHintControlMatch(uiHint.Id, uiHint.Id, new Dictionary <string, object>()));
                }
            }

            if (type.IsInterface)
            {
                return(new PolymorphicControlMatch("polymorphic-form", PolymorphicFormFinder.FindFor(type).ToList().AsReadOnly()));
            }

            return(null);
        }