Пример #1
0
        internal static Optional <IPrettifier> FindPrettifier(
            IPrettifierDatabase prettifierDatabase,
            [NotNull]   Type type,
            [CanBeNull] PrettificationSettings settings,
            [NotNull, ItemNotNull, InstantHandle]
            IEnumerable <OptionalPrettifierFinder> finders
            )
        {
            settings = Prettification.ResolveSettings(settings);
            settings.TraceWriter.Verbose(() => $"🔎 Attempting to find an {nameof(IPrettifier)} for the type {type.Name}");
            var simplified = PrettificationTypeSimplifier.SimplifyType(type, settings);

            var prettifier = Optional.Optional.FirstWithValue <OptionalPrettifierFinder, IPrettifier>(
                finders,
                prettifierDatabase,
                simplified,
                settings
                );

            settings.TraceWriter.Info(
                () => prettifier.IfPresentOrElse(
                    it => $"⛳ Found: {it}",
                    () => "🐸 No prettifier found!"
                    ),
                2
                );

            return(prettifier);
        }
Пример #2
0
 public Prettifier([NotNull] Func <T, PrettificationSettings, string> prettifierFunc)
 {
     PrettificationFunction = prettifierFunc;
     PrettifierType         = PrettificationTypeSimplifier.SimplifyType(typeof(T), new PrettificationSettings());
 }